@@ -29,7 +29,7 @@ type WorkspaceServerConfig struct {
2929// It creates and manages network server instance as well as
3030// all services that run on DevPod network inside the workspace.
3131type WorkspaceServer struct {
32- tsServer * tsnet.Server
32+ network * tsnet.Server // TODO: we probably want to hide network behind our own interface at some point
3333 config * WorkspaceServerConfig
3434 log log.Logger
3535 connTracker * ConnTracker
@@ -55,47 +55,47 @@ func NewWorkspaceServer(config *WorkspaceServerConfig, logger log.Logger) *Works
5555// Start initializes the network server server and all services, then blocks until the context is canceled.
5656func (s * WorkspaceServer ) Start (ctx context.Context ) error {
5757 s .log .Infof ("Starting workspace server" )
58- workspaceName , projectName , err := s .setupTSNet (ctx )
58+ workspaceName , projectName , err := s .joinNetwork (ctx )
5959 if err != nil {
6060 return err
6161 }
6262
63- lc , err := s .tsServer .LocalClient ()
63+ lc , err := s .network .LocalClient ()
6464 if err != nil {
6565 return err
6666 }
6767
6868 // Create and start the SSH service.
69- s .sshSvc , err = NewSSHServer (s .tsServer , s .connTracker , s .log )
69+ s .sshSvc , err = NewSSHService (s .network , s .connTracker , s .log )
7070 if err != nil {
7171 return err
7272 }
7373 s .sshSvc .Start (ctx )
7474
7575 // Create and start the HTTP port forward service.
76- s .httpProxySvc , err = NewHTTPPortForwardService (s .tsServer , s .connTracker , s .log )
76+ s .httpProxySvc , err = NewHTTPPortForwardService (s .network , s .connTracker , s .log )
7777 if err != nil {
7878 return err
7979 }
8080 s .httpProxySvc .Start (ctx )
8181
8282 // Create and start the platform git credentials service.
83- s .platformGitCredentialsSvc , err = NewPlatformGitCredentialsService (s .config , s .tsServer , lc , projectName , workspaceName , s .log )
83+ s .platformGitCredentialsSvc , err = NewPlatformGitCredentialsService (s .config , s .network , lc , projectName , workspaceName , s .log )
8484 if err != nil {
8585 return err
8686 }
8787 s .platformGitCredentialsSvc .Start (ctx )
8888
89- // Create and start the TS proxy service.
90- tsProxySocket := filepath .Join (s .config .RootDir , TSNetProxySocket )
91- s .netProxySvc , err = NewNetworkProxyService (tsProxySocket , s .tsServer , s .log )
89+ // Create and start the network proxy service.
90+ networkSocket := filepath .Join (s .config .RootDir , NetworkProxySocket )
91+ s .netProxySvc , err = NewNetworkProxyService (networkSocket , s .network , s .log )
9292 if err != nil {
9393 return err
9494 }
9595 s .netProxySvc .Start (ctx )
9696
9797 // Start the heartbeat service.
98- s .heartbeatSvc = NewHeartbeatService (s .config , s .tsServer , lc , projectName , workspaceName , s .connTracker , s .log )
98+ s .heartbeatSvc = NewHeartbeatService (s .config , s .network , lc , projectName , workspaceName , s .connTracker , s .log )
9999 go s .heartbeatSvc .Start (ctx )
100100
101101 // Start netmap watcher.
@@ -107,7 +107,7 @@ func (s *WorkspaceServer) Start(ctx context.Context) error {
107107 return nil
108108}
109109
110- // Stop shuts down all sub-servers and the TSNet server.
110+ // Stop shuts down all services and the network server.
111111func (s * WorkspaceServer ) Stop () {
112112 if s .sshSvc != nil {
113113 s .sshSvc .Stop ()
@@ -121,32 +121,32 @@ func (s *WorkspaceServer) Stop() {
121121 if s .netProxySvc != nil {
122122 s .netProxySvc .Stop ()
123123 }
124- if s .tsServer != nil {
125- s .tsServer .Close ()
126- s .tsServer = nil
124+ if s .network != nil {
125+ s .network .Close ()
126+ s .network = nil
127127 }
128128 s .log .Info ("Workspace server stopped" )
129129}
130130
131- // Dial dials the given address using the TSNet server.
131+ // Dial dials the given address using the network server.
132132func (s * WorkspaceServer ) Dial (ctx context.Context , network , addr string ) (net.Conn , error ) {
133- if s .tsServer == nil {
134- return nil , fmt .Errorf ("tailscale server is not running" )
133+ if s .network == nil {
134+ return nil , fmt .Errorf ("network server is not running" )
135135 }
136- return s .tsServer .Dial (ctx , network , addr )
136+ return s .network .Dial (ctx , network , addr )
137137}
138138
139- // setupTSNet validates configuration, sets up the control URL, starts the TSNet server,
139+ // joinNetwork validates configuration, sets up the control URL, starts the network server,
140140// and parses the hostname into workspace and project names.
141- func (s * WorkspaceServer ) setupTSNet (ctx context.Context ) (workspace , project string , err error ) {
141+ func (s * WorkspaceServer ) joinNetwork (ctx context.Context ) (workspace , project string , err error ) {
142142 if err = s .validateConfig (); err != nil {
143143 return "" , "" , err
144144 }
145145 baseURL , err := s .setupControlURL (ctx )
146146 if err != nil {
147147 return "" , "" , err
148148 }
149- if err = s .initTsServer (ctx , baseURL ); err != nil {
149+ if err = s .initNetworkServer (ctx , baseURL ); err != nil {
150150 return "" , "" , err
151151 }
152152 return s .parseWorkspaceHostname ()
@@ -170,11 +170,11 @@ func (s *WorkspaceServer) setupControlURL(ctx context.Context) (*url.URL, error)
170170 return baseURL , nil
171171}
172172
173- func (s * WorkspaceServer ) initTsServer (ctx context.Context , controlURL * url.URL ) error {
173+ func (s * WorkspaceServer ) initNetworkServer (ctx context.Context , controlURL * url.URL ) error {
174174 store , _ := mem .New (s .config .LogF , "" )
175175 envknob .Setenv ("TS_DEBUG_TLS_DIAL_INSECURE_SKIP_VERIFY" , "true" )
176176 s .log .Infof ("Connecting to control URL - %s/coordinator/" , controlURL .String ())
177- s .tsServer = & tsnet.Server {
177+ s .network = & tsnet.Server { // TODO: this probably could be extracted from here and local daemon into pkg/ts
178178 Hostname : s .config .WorkspaceHost ,
179179 Logf : s .config .LogF ,
180180 ControlURL : controlURL .String () + "/coordinator/" ,
@@ -183,7 +183,7 @@ func (s *WorkspaceServer) initTsServer(ctx context.Context, controlURL *url.URL)
183183 Ephemeral : true ,
184184 Store : store ,
185185 }
186- if _ , err := s .tsServer .Up (ctx ); err != nil {
186+ if _ , err := s .network .Up (ctx ); err != nil {
187187 return err
188188 }
189189 return nil
0 commit comments