Compare commits
	
		
			No commits in common. "c5100b35bf17e9afaca20ac9c1d3ed0a93814236" and "dd9fff02a1b3dd91f8c93cf3ce6d44a231d2353a" have entirely different histories.
		
	
	
		
			c5100b35bf
			...
			dd9fff02a1
		
	
		
| @ -83,7 +83,6 @@ func handleTelnetConn(bufConn bufferedConn) { | |||||||
| 				email = strings.TrimSpace(msg) | 				email = strings.TrimSpace(msg) | ||||||
| 				emailParts := strings.Split(email, "@") | 				emailParts := strings.Split(email, "@") | ||||||
| 				if 2 != len(emailParts) { | 				if 2 != len(emailParts) { | ||||||
| 					email = "" |  | ||||||
| 					fmt.Fprintf(bufConn, "Email: ") | 					fmt.Fprintf(bufConn, "Email: ") | ||||||
| 					continue | 					continue | ||||||
| 				} | 				} | ||||||
|  | |||||||
| @ -10,6 +10,7 @@ import ( | |||||||
| 	"encoding/base64" | 	"encoding/base64" | ||||||
| 	"flag" | 	"flag" | ||||||
| 	"fmt" | 	"fmt" | ||||||
|  | 	"io" | ||||||
| 	"io/ioutil" | 	"io/ioutil" | ||||||
| 	"net" | 	"net" | ||||||
| 	"net/http" | 	"net/http" | ||||||
| @ -41,13 +42,13 @@ type ConfMailer struct { | |||||||
| // So we can peek at net.Conn, which we can't do natively | // So we can peek at net.Conn, which we can't do natively | ||||||
| // https://stackoverflow.com/questions/51472020/how-to-get-the-size-of-available-tcp-data | // https://stackoverflow.com/questions/51472020/how-to-get-the-size-of-available-tcp-data | ||||||
| type bufferedConn struct { | type bufferedConn struct { | ||||||
| 	r *bufio.Reader | 	r    *bufio.Reader | ||||||
| 	//rout *io.Reader // See https://github.com/polvi/sni/blob/master/sni.go#L135 | 	rout io.Reader // See https://github.com/polvi/sni/blob/master/sni.go#L135 | ||||||
| 	net.Conn | 	net.Conn | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func newBufferedConn(c net.Conn) bufferedConn { | func newBufferedConn(c net.Conn) bufferedConn { | ||||||
| 	return bufferedConn{bufio.NewReader(c), c} | 	return bufferedConn{bufio.NewReader(c), nil, c} | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (b bufferedConn) Peek(n int) ([]byte, error) { | func (b bufferedConn) Peek(n int) ([]byte, error) { | ||||||
| @ -59,11 +60,9 @@ func (b bufferedConn) Buffered() int { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| func (b bufferedConn) Read(p []byte) (int, error) { | func (b bufferedConn) Read(p []byte) (int, error) { | ||||||
| 	/* | 	if b.rout != nil { | ||||||
| 		if b.rout != nil { | 		return b.rout.Read(p) | ||||||
| 			return b.rout.Read(p) | 	} | ||||||
| 		} |  | ||||||
| 	*/ |  | ||||||
| 	return b.r.Read(p) | 	return b.r.Read(p) | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| @ -167,9 +166,6 @@ func muxTcp(conn bufferedConn) { | |||||||
| 	} | 	} | ||||||
| 
 | 
 | ||||||
| 	if "" == protocol { | 	if "" == protocol { | ||||||
| 		// Throw away the first bytes |  | ||||||
| 		b := make([]byte, 4096) |  | ||||||
| 		conn.Read(b) |  | ||||||
| 		fmt.Fprintf(conn, "\n\nWelcome to Sample Chat! You're not an HTTP client, assuming Telnet.\nYou must authenticate via email to participate\n\nEmail: ") | 		fmt.Fprintf(conn, "\n\nWelcome to Sample Chat! You're not an HTTP client, assuming Telnet.\nYou must authenticate via email to participate\n\nEmail: ") | ||||||
| 		wantsServerHello <- conn | 		wantsServerHello <- conn | ||||||
| 		return | 		return | ||||||
|  | |||||||
| @ -10,7 +10,7 @@ | |||||||
|     <li> |     <li> | ||||||
|     <h3>POST /api/sessions |     <h3>POST /api/sessions | ||||||
|     <br> |     <br> | ||||||
|     <code>{"sub":"<strong><em><email></em></strong>"}</code> |     <code>{"sub":"<strong><em>jon@example.com</em></strong>"}</code> | ||||||
|     </h3> |     </h3> | ||||||
|     <pre><code># Ask for an auth code (swap sub) |     <pre><code># Ask for an auth code (swap sub) | ||||||
| 
 | 
 | ||||||
| @ -21,9 +21,9 @@ curl -X POST http://localhost:4080/api/sessions \ | |||||||
|     </li> |     </li> | ||||||
| 
 | 
 | ||||||
|     <li> |     <li> | ||||||
|     <h3>POST /api/sessions/<strong><em><id></em></strong> |     <h3>POST /api/sessions/<strong><em>id</em></strong> | ||||||
|     <br> |     <br> | ||||||
|     <code>{"otp":"<strong><em><auth-code></em></strong>"}</code> |     <code>{"otp":"<strong><em>auth-code</em></strong>"}</code> | ||||||
|     </h3> |     </h3> | ||||||
|     <pre><code># Validate auth code (swap session id, sub, and otp) |     <pre><code># Validate auth code (swap session id, sub, and otp) | ||||||
| 
 | 
 | ||||||
| @ -39,8 +39,8 @@ curl -X POST http://localhost:4080/api/sessions/<strong><em>xyz</em></strong> \ | |||||||
|     <li> |     <li> | ||||||
|     <h3>POST /api/rooms/general |     <h3>POST /api/rooms/general | ||||||
|     <br> |     <br> | ||||||
|     <code>Authorization: Bearer <strong><em><api-token></em></strong> |     <code>Authorization: Bearer <strong><em>api-token</em></strong> | ||||||
|     <br>{"message":"<strong><em><msg></em></strong>"}</code> |     <br>{"message":"<strong><em>Hello, World!</em></strong>"}</code> | ||||||
|     </h3> |     </h3> | ||||||
|     <pre><code># Post a message (swap api-token) |     <pre><code># Post a message (swap api-token) | ||||||
| 
 | 
 | ||||||
| @ -54,7 +54,8 @@ curl -X POST http://localhost:4080/api/rooms/general \ | |||||||
|     <li> |     <li> | ||||||
|     <h3>GET /api/rooms/general |     <h3>GET /api/rooms/general | ||||||
|     <br> |     <br> | ||||||
|     <code>Authorization: Bearer <strong><em><api-token></em></strong></code> |     <code>Authorization: Bearer <strong><em>api-token</em></strong> | ||||||
|  |     <br>{"message":"<strong><em>Hello, World!</em></strong>"}</code> | ||||||
|     </h3> |     </h3> | ||||||
|     <pre><code># Get a room's messages (swap api-token, since unix-epoch) |     <pre><code># Get a room's messages (swap api-token, since unix-epoch) | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user