-
Notifications
You must be signed in to change notification settings - Fork 1
pass team member ID to proxy through header #278
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| # diagrams | ||
|
|
||
| Temporary file for updated diagrams from the [README](./README.md) done natively in mermaid to allow version-controlled updates. | ||
|
|
||
| ```mermaid | ||
| flowchart LR | ||
| subgraph blocked-peer | ||
| client | ||
| end | ||
| subgraph unbounded.lantern.io | ||
| widget | ||
| leaderboard | ||
| end | ||
| subgraph matchmaking | ||
| freddie <--> widget | ||
| end | ||
| subgraph lantern-cloud | ||
| subgraph http-proxy | ||
| widget <==> |WebSocket| egress | ||
| end | ||
| egress-->redis[(redis)] | ||
| redis-.->api | ||
| api<-->db[(database)] | ||
| end | ||
| client <==> |proxy| widget | ||
| client <--> freddie | ||
| api --> leaderboard | ||
| internet((open internet)) <==> egress | ||
| ``` |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -105,10 +105,12 @@ func (q websocketPacketConn) LocalAddr() net.Addr { | |
|
|
||
| type proxyListener struct { | ||
| net.Listener | ||
| connections chan net.Conn | ||
| tlsConfig *tls.Config | ||
| addr net.Addr | ||
| closeMetrics func(ctx context.Context) error | ||
| connections chan net.Conn | ||
| tlsConfig *tls.Config | ||
| addr net.Addr | ||
| closeMetrics func(ctx context.Context) error | ||
| ReportConnection func(ctx context.Context) error // TODO should we use a method here? | ||
| ReportBytes func(ctx context.Context) error // TODO same, and do we have a way to track bytes? | ||
|
Comment on lines
+112
to
+113
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. currently unused, but kept in as a placeholder for a "insert reporting func" structure that isn't too specifically tied to lantern-cloud |
||
| } | ||
|
|
||
| func (l proxyListener) Accept() (net.Conn, error) { | ||
|
|
@@ -191,6 +193,10 @@ func (l proxyListener) handleWebsocket(w http.ResponseWriter, r *http.Request) { | |
| common.Debugf("Accepted a new WebSocket connection! (%v total)", atomic.AddUint64(&nClients, 1)) | ||
| nClientsCounter.Add(context.Background(), 1) | ||
|
|
||
| // check for optional tracking identifier for donors who wish to be credited the facilitated connections | ||
| unboundedID := r.Header.Get("X-Unbounded") | ||
| common.Debugf("X-Unbounded: %v", unboundedID) | ||
|
|
||
| listener, err := quic.Listen(wspconn, l.tlsConfig, &common.QUICCfg) | ||
| if err != nil { | ||
| common.Debugf("Error creating QUIC listener: %v", err) | ||
|
|
@@ -208,6 +214,11 @@ func (l proxyListener) handleWebsocket(w http.ResponseWriter, r *http.Request) { | |
| nQUICConnectionsCounter.Add(context.Background(), 1) | ||
| common.Debugf("%v accepted a new QUIC connection!", wspconn.addr) | ||
|
|
||
| go func() { | ||
| // TODO record a connection | ||
| common.Debugf("[placeholder] POST new connection for ID: %v", unboundedID) | ||
|
Comment on lines
+218
to
+219
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. placeholder: report to redis |
||
| }() | ||
|
|
||
| go func() { | ||
| for { | ||
| stream, err := conn.AcceptStream(context.Background()) | ||
|
|
@@ -223,6 +234,10 @@ func (l proxyListener) handleWebsocket(w http.ResponseWriter, r *http.Request) { | |
| } | ||
|
|
||
| common.Debugf("Accepted a new QUIC stream! (%v total)", atomic.AddUint64(&nQUICStreams, 1)) | ||
|
|
||
| // TODO what is the relationship between a connection and a stream? 1:1? | ||
| // if not, should be be recording streams? | ||
|
|
||
|
Comment on lines
+238
to
+240
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. does it matter to count streams? |
||
| nQUICStreamsCounter.Add(context.Background(), 1) | ||
|
|
||
| l.connections <- common.QUICStreamNetConn{ | ||
|
|
@@ -240,9 +255,9 @@ func (l proxyListener) handleWebsocket(w http.ResponseWriter, r *http.Request) { | |
| } | ||
|
|
||
| func NewListener(ctx context.Context, ll net.Listener, certPEM, keyPEM string) (net.Listener, error) { | ||
| var err error | ||
| closeFuncMetric := telemetry.EnableOTELMetrics(ctx) | ||
| m := otel.Meter("github.com/getlantern/broflake/egress") | ||
| var err error | ||
| nClientsCounter, err = m.Int64UpDownCounter("concurrent-websockets") | ||
| if err != nil { | ||
| closeFuncMetric(ctx) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A contributing team member's ID could be obtained when the user logs in, and set somewhere that it can be read and added to egress websocket connections.
How should that ID be known here?