fix first connection
This commit is contained in:
parent
10778eaab1
commit
d3f8b90e32
|
@ -178,6 +178,9 @@ func upgradeWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||||
MultiEncoder: telebit.NewEncoder(context.TODO(), wsTun),
|
MultiEncoder: telebit.NewEncoder(context.TODO(), wsTun),
|
||||||
MultiDecoder: telebit.NewDecoder(wsTun),
|
MultiDecoder: telebit.NewDecoder(wsTun),
|
||||||
}
|
}
|
||||||
|
// TODO should this happen at NewEncoder()?
|
||||||
|
// (or is it even necessary anymore?)
|
||||||
|
_ = server.MultiEncoder.Start()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// (this listener is also a telebit.Router)
|
// (this listener is also a telebit.Router)
|
||||||
|
@ -187,6 +190,7 @@ func upgradeWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||||
// there's an encoder with a callback between the websocket
|
// there's an encoder with a callback between the websocket
|
||||||
// and the multiplexer, so it doesn't know to stop listening otherwise
|
// and the multiplexer, so it doesn't know to stop listening otherwise
|
||||||
_ = wsTun.Close()
|
_ = wsTun.Close()
|
||||||
|
// TODO close all clients
|
||||||
fmt.Printf("a subscriber stream is done: %q\n", err)
|
fmt.Printf("a subscriber stream is done: %q\n", err)
|
||||||
}()
|
}()
|
||||||
|
|
||||||
|
|
|
@ -359,7 +359,7 @@ func routeSubscribersAndClients(client net.Conn) error {
|
||||||
// Match full servername "sub.domain.example.com"
|
// Match full servername "sub.domain.example.com"
|
||||||
if tryToServeName(servername, wconn) {
|
if tryToServeName(servername, wconn) {
|
||||||
// TODO better non-error
|
// TODO better non-error
|
||||||
return io.EOF
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// Match wild names
|
// Match wild names
|
||||||
|
|
|
@ -229,6 +229,9 @@ func upgradeWebsocket(w http.ResponseWriter, r *http.Request) {
|
||||||
MultiEncoder: telebit.NewEncoder(context.TODO(), wsTun),
|
MultiEncoder: telebit.NewEncoder(context.TODO(), wsTun),
|
||||||
MultiDecoder: telebit.NewDecoder(wsTun),
|
MultiDecoder: telebit.NewDecoder(wsTun),
|
||||||
}
|
}
|
||||||
|
// TODO should this happen at NewEncoder()?
|
||||||
|
// (or is it even necessary anymore?)
|
||||||
|
_ = server.MultiEncoder.Start()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
// (this listener is also a telebit.Router)
|
// (this listener is also a telebit.Router)
|
||||||
|
|
|
@ -16,7 +16,7 @@ ACME_EMAIL="${ACME_EMAIL:-}"
|
||||||
|
|
||||||
./telebit --acme-agree=true \
|
./telebit --acme-agree=true \
|
||||||
--admin-hostname $ADMIN_HOSTNAME \
|
--admin-hostname $ADMIN_HOSTNAME \
|
||||||
--auth-url $AUTH_URL/api \
|
--auth-url $AUTH_URL \
|
||||||
--acme-email "$ACME_EMAIL" \
|
--acme-email "$ACME_EMAIL" \
|
||||||
--secret "$SECRET" \
|
--secret "$SECRET" \
|
||||||
--listen 3020,3030
|
--listen 3020,3030
|
||||||
|
|
|
@ -54,6 +54,11 @@ func (enc *Encoder) Run() error {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (enc *Encoder) Start() error {
|
||||||
|
go enc.Run()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// Encode adds MPLEXY headers to raw net traffic, and is intended to be used on each client connection
|
// Encode adds MPLEXY headers to raw net traffic, and is intended to be used on each client connection
|
||||||
func (enc *Encoder) Encode(rin io.Reader, src, dst Addr) error {
|
func (enc *Encoder) Encode(rin io.Reader, src, dst Addr) error {
|
||||||
rx := make(chan []byte)
|
rx := make(chan []byte)
|
||||||
|
|
|
@ -124,8 +124,8 @@ func (s *SubscriberConn) Serve(client net.Conn) error {
|
||||||
id := client.RemoteAddr().String()
|
id := client.RemoteAddr().String()
|
||||||
s.Clients.Store(id, client)
|
s.Clients.Store(id, client)
|
||||||
|
|
||||||
fmt.Println("[debug] cancel all the clients")
|
//fmt.Println("[debug] immediately cancel client to simplify testing / debugging")
|
||||||
_ = client.Close()
|
//_ = client.Close()
|
||||||
|
|
||||||
// TODO
|
// TODO
|
||||||
// - Encode each client to the tunnel
|
// - Encode each client to the tunnel
|
||||||
|
|
Loading…
Reference in New Issue