@@ -29,7 +29,7 @@ type WorkspaceServerConfig struct {
29
29
// It creates and manages network server instance as well as
30
30
// all services that run on DevPod network inside the workspace.
31
31
type WorkspaceServer struct {
32
- tsServer * tsnet.Server
32
+ network * tsnet.Server // TODO: we probably want to hide network behind our own interface at some point
33
33
config * WorkspaceServerConfig
34
34
log log.Logger
35
35
connTracker * ConnTracker
@@ -55,47 +55,47 @@ func NewWorkspaceServer(config *WorkspaceServerConfig, logger log.Logger) *Works
55
55
// Start initializes the network server server and all services, then blocks until the context is canceled.
56
56
func (s * WorkspaceServer ) Start (ctx context.Context ) error {
57
57
s .log .Infof ("Starting workspace server" )
58
- workspaceName , projectName , err := s .setupTSNet (ctx )
58
+ workspaceName , projectName , err := s .joinNetwork (ctx )
59
59
if err != nil {
60
60
return err
61
61
}
62
62
63
- lc , err := s .tsServer .LocalClient ()
63
+ lc , err := s .network .LocalClient ()
64
64
if err != nil {
65
65
return err
66
66
}
67
67
68
68
// Create and start the SSH service.
69
- s .sshSvc , err = NewSSHServer (s .tsServer , s .connTracker , s .log )
69
+ s .sshSvc , err = NewSSHServer (s .network , s .connTracker , s .log )
70
70
if err != nil {
71
71
return err
72
72
}
73
73
s .sshSvc .Start (ctx )
74
74
75
75
// 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 )
77
77
if err != nil {
78
78
return err
79
79
}
80
80
s .httpProxySvc .Start (ctx )
81
81
82
82
// 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 )
84
84
if err != nil {
85
85
return err
86
86
}
87
87
s .platformGitCredentialsSvc .Start (ctx )
88
88
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 )
92
92
if err != nil {
93
93
return err
94
94
}
95
95
s .netProxySvc .Start (ctx )
96
96
97
97
// 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 )
99
99
go s .heartbeatSvc .Start (ctx )
100
100
101
101
// Start netmap watcher.
@@ -107,7 +107,7 @@ func (s *WorkspaceServer) Start(ctx context.Context) error {
107
107
return nil
108
108
}
109
109
110
- // Stop shuts down all sub-servers and the TSNet server.
110
+ // Stop shuts down all services and the network server.
111
111
func (s * WorkspaceServer ) Stop () {
112
112
if s .sshSvc != nil {
113
113
s .sshSvc .Stop ()
@@ -121,32 +121,32 @@ func (s *WorkspaceServer) Stop() {
121
121
if s .netProxySvc != nil {
122
122
s .netProxySvc .Stop ()
123
123
}
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
127
127
}
128
128
s .log .Info ("Workspace server stopped" )
129
129
}
130
130
131
- // Dial dials the given address using the TSNet server.
131
+ // Dial dials the given address using the network server.
132
132
func (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" )
135
135
}
136
- return s .tsServer .Dial (ctx , network , addr )
136
+ return s .network .Dial (ctx , network , addr )
137
137
}
138
138
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,
140
140
// 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 ) {
142
142
if err = s .validateConfig (); err != nil {
143
143
return "" , "" , err
144
144
}
145
145
baseURL , err := s .setupControlURL (ctx )
146
146
if err != nil {
147
147
return "" , "" , err
148
148
}
149
- if err = s .initTsServer (ctx , baseURL ); err != nil {
149
+ if err = s .initNetworkServer (ctx , baseURL ); err != nil {
150
150
return "" , "" , err
151
151
}
152
152
return s .parseWorkspaceHostname ()
@@ -170,11 +170,11 @@ func (s *WorkspaceServer) setupControlURL(ctx context.Context) (*url.URL, error)
170
170
return baseURL , nil
171
171
}
172
172
173
- func (s * WorkspaceServer ) initTsServer (ctx context.Context , controlURL * url.URL ) error {
173
+ func (s * WorkspaceServer ) initNetworkServer (ctx context.Context , controlURL * url.URL ) error {
174
174
store , _ := mem .New (s .config .LogF , "" )
175
175
envknob .Setenv ("TS_DEBUG_TLS_DIAL_INSECURE_SKIP_VERIFY" , "true" )
176
176
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
178
178
Hostname : s .config .WorkspaceHost ,
179
179
Logf : s .config .LogF ,
180
180
ControlURL : controlURL .String () + "/coordinator/" ,
@@ -183,7 +183,7 @@ func (s *WorkspaceServer) initTsServer(ctx context.Context, controlURL *url.URL)
183
183
Ephemeral : true ,
184
184
Store : store ,
185
185
}
186
- if _ , err := s .tsServer .Up (ctx ); err != nil {
186
+ if _ , err := s .network .Up (ctx ); err != nil {
187
187
return err
188
188
}
189
189
return nil
0 commit comments