Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 73a8d7e

Browse files
committed
linting
1 parent c516b44 commit 73a8d7e

File tree

2 files changed

+7
-76
lines changed

2 files changed

+7
-76
lines changed

coderd/workspaceagents.go

Lines changed: 0 additions & 70 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@ import (
2323
"github.com/coder/coder/coderd/httpapi"
2424
"github.com/coder/coder/coderd/httpmw"
2525
"github.com/coder/coder/coderd/rbac"
26-
"github.com/coder/coder/coderd/turnconn"
2726
"github.com/coder/coder/codersdk"
28-
"github.com/coder/coder/peer"
2927
"github.com/coder/coder/peerbroker"
3028
"github.com/coder/coder/peerbroker/proto"
3129
"github.com/coder/coder/provisionersdk"
@@ -468,74 +466,6 @@ func (api *API) dialWorkspaceAgentTailnet(r *http.Request, agentID uuid.UUID) (a
468466
}, nil
469467
}
470468

471-
// dialWorkspaceAgent connects to a workspace agent by ID. Only rely on
472-
// r.Context() for cancellation if it's use is safe or r.Hijack() has
473-
// not been performed.
474-
func (api *API) dialWorkspaceAgent(r *http.Request, agentID uuid.UUID) (agent.Conn, error) {
475-
client, server := provisionersdk.TransportPipe()
476-
ctx, cancelFunc := context.WithCancel(context.Background())
477-
go func() {
478-
_ = peerbroker.ProxyListen(ctx, server, peerbroker.ProxyOptions{
479-
ChannelID: agentID.String(),
480-
Logger: api.Logger.Named("peerbroker-proxy-dial"),
481-
Pubsub: api.Pubsub,
482-
})
483-
_ = client.Close()
484-
_ = server.Close()
485-
}()
486-
487-
peerClient := proto.NewDRPCPeerBrokerClient(provisionersdk.Conn(client))
488-
stream, err := peerClient.NegotiateConnection(ctx)
489-
if err != nil {
490-
cancelFunc()
491-
return nil, xerrors.Errorf("negotiate: %w", err)
492-
}
493-
options := &peer.ConnOptions{
494-
Logger: api.Logger.Named("agent-dialer"),
495-
}
496-
options.SettingEngine.SetSrflxAcceptanceMinWait(0)
497-
options.SettingEngine.SetRelayAcceptanceMinWait(0)
498-
// Use the ProxyDialer for the TURN server.
499-
// This is required for connections where P2P is not enabled.
500-
options.SettingEngine.SetICEProxyDialer(turnconn.ProxyDialer(func() (c net.Conn, err error) {
501-
clientPipe, serverPipe := net.Pipe()
502-
go func() {
503-
<-ctx.Done()
504-
_ = clientPipe.Close()
505-
_ = serverPipe.Close()
506-
}()
507-
localAddress, _ := r.Context().Value(http.LocalAddrContextKey).(*net.TCPAddr)
508-
remoteAddress := &net.TCPAddr{
509-
IP: net.ParseIP(r.RemoteAddr),
510-
}
511-
// By default requests have the remote address and port.
512-
host, port, err := net.SplitHostPort(r.RemoteAddr)
513-
if err != nil {
514-
return nil, xerrors.Errorf("split remote address: %w", err)
515-
}
516-
remoteAddress.IP = net.ParseIP(host)
517-
remoteAddress.Port, err = strconv.Atoi(port)
518-
if err != nil {
519-
return nil, xerrors.Errorf("convert remote port: %w", err)
520-
}
521-
api.TURNServer.Accept(clientPipe, remoteAddress, localAddress)
522-
return serverPipe, nil
523-
}))
524-
peerConn, err := peerbroker.Dial(stream, append(api.ICEServers, turnconn.Proxy), options)
525-
if err != nil {
526-
cancelFunc()
527-
return nil, xerrors.Errorf("dial: %w", err)
528-
}
529-
go func() {
530-
<-peerConn.Closed()
531-
cancelFunc()
532-
}()
533-
return &agent.WebRTCConn{
534-
Negotiator: peerClient,
535-
Conn: peerConn,
536-
}, nil
537-
}
538-
539469
func (api *API) workspaceAgentConnection(rw http.ResponseWriter, r *http.Request) {
540470
workspace := httpmw.WorkspaceParam(r)
541471
if !api.Authorize(r, rbac.ActionRead, workspace) {

enterprise/coderd/licenses.go

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ var ValidMethods = []string{"EdDSA"}
3333

3434
// key20220812 is the Coder license public key with id 2022-08-12 used to validate licenses signed
3535
// by our signing infrastructure
36+
//
3637
//go:embed keys/2022-08-12
3738
var key20220812 []byte
3839

@@ -129,12 +130,12 @@ func (a *licenseAPI) handler() http.Handler {
129130
// postLicense adds a new Enterprise license to the cluster. We allow multiple different licenses
130131
// in the cluster at one time for several reasons:
131132
//
132-
// 1. Upgrades --- if the license format changes from one version of Coder to the next, during a
133-
// rolling update you will have different Coder servers that need different licenses to function.
134-
// 2. Avoid abrupt feature breakage --- when an admin uploads a new license with different features
135-
// we generally don't want the old features to immediately break without warning. With a grace
136-
// period on the license, features will continue to work from the old license until its grace
137-
// period, then the users will get a warning allowing them to gracefully stop using the feature.
133+
// 1. Upgrades --- if the license format changes from one version of Coder to the next, during a
134+
// rolling update you will have different Coder servers that need different licenses to function.
135+
// 2. Avoid abrupt feature breakage --- when an admin uploads a new license with different features
136+
// we generally don't want the old features to immediately break without warning. With a grace
137+
// period on the license, features will continue to work from the old license until its grace
138+
// period, then the users will get a warning allowing them to gracefully stop using the feature.
138139
func (a *licenseAPI) postLicense(rw http.ResponseWriter, r *http.Request) {
139140
if !a.auth.Authorize(r, rbac.ActionCreate, rbac.ResourceLicense) {
140141
httpapi.Forbidden(rw)

0 commit comments

Comments
 (0)