@@ -126,9 +126,9 @@ func TestMain(m *testing.M) {
126
126
os .Exit (code )
127
127
}
128
128
129
- //prepareTunnel creates a Tunnel object making sure all infrastructure
130
- //dependencies (ssh and http servers) are ready returning a connection that
131
- //can be use to reach the remote http server through the tunnel.
129
+ // prepareTunnel creates a Tunnel object making sure all infrastructure
130
+ // dependencies (ssh and http servers) are ready returning a connection that
131
+ // can be use to reach the remote http server through the tunnel.
132
132
func prepareTunnel (t * testing.T ) net.Conn {
133
133
sshAddr := createSSHServer (keyPath )
134
134
generateKnownHosts (sshAddr .String (), publicKeyPath , knownHostsPath )
@@ -191,8 +191,8 @@ func prepareTestEnv() {
191
191
os .Setenv ("HOME" , home )
192
192
}
193
193
194
- //newHttpClient create an http client that will always use the given connection
195
- //to perform http requests.
194
+ // newHttpClient create an http client that will always use the given
195
+ // connection to perform http requests.
196
196
func newHttpClient (conn net.Conn ) http.Client {
197
197
tr := & http.Transport {
198
198
Dial : func (network , address string ) (net.Conn , error ) {
@@ -208,11 +208,11 @@ func newHttpClient(conn net.Conn) http.Client {
208
208
return client
209
209
}
210
210
211
- //get performs a http request using the given client appending the given
212
- //resource to to a hard-coded URL.
211
+ // get performs a http request using the given client appending the given
212
+ // resource to to a hard-coded URL.
213
213
//
214
- //The request performed by this function is designed to reach the other side
215
- //through a pipe (net.Pipe()) and this is the reason the URL is hard-coded.
214
+ // The request performed by this function is designed to reach the other side
215
+ // through a pipe (net.Pipe()) and this is the reason the URL is hard-coded.
216
216
func get (client http.Client , resource string ) (string , error ) {
217
217
resp , err := client .Get (fmt .Sprintf ("%s%s" , "http://any-url-is.fine" , resource ))
218
218
if err != nil {
@@ -225,11 +225,11 @@ func get(client http.Client, resource string) (string, error) {
225
225
return string (body ), nil
226
226
}
227
227
228
- //createWebServer spawns a new http server, listening on a random user port and
229
- //providing a response identical to the resource provided by the request.
228
+ // createWebServer spawns a new http server, listening on a random user port
229
+ // and providing a response identical to the resource provided by the request.
230
230
//
231
- //Example: If the request URI is /this-is-a-test, the response will be
232
- //this-is-a-test
231
+ // Example: If the request URI is /this-is-a-test, the response will be
232
+ // this-is-a-test
233
233
func createWebServer () net.Addr {
234
234
235
235
handler := func (w http.ResponseWriter , r * http.Request ) {
@@ -245,16 +245,16 @@ func createWebServer() net.Addr {
245
245
return l .Addr ()
246
246
}
247
247
248
- //createSSHServer starts a SSH server that authenticates connections using
249
- //the given keyPath, listens on a random user port and returns the SSH Server
250
- //address.
248
+ // createSSHServer starts a SSH server that authenticates connections using
249
+ // the given keyPath, listens on a random user port and returns the SSH Server
250
+ // address.
251
251
//
252
- //The SSH Server created by this function only responds to "direct-tcpip",
253
- //which is used to establish local port forwarding.
252
+ // The SSH Server created by this function only responds to "direct-tcpip",
253
+ // which is used to establish local port forwarding.
254
254
//
255
- //References:
256
- //https://gist.github.com/jpillora/b480fde82bff51a06238
257
- //https://tools.ietf.org/html/rfc4254#section-7.2
255
+ // References:
256
+ // https://gist.github.com/jpillora/b480fde82bff51a06238
257
+ // https://tools.ietf.org/html/rfc4254#section-7.2
258
258
func createSSHServer (keyPath string ) net.Addr {
259
259
conf := & ssh.ServerConfig {
260
260
PublicKeyCallback : func (conn ssh.ConnMetadata , key ssh.PublicKey ) (* ssh.Permissions , error ) {
@@ -309,8 +309,8 @@ func createSSHServer(keyPath string) net.Addr {
309
309
return l .Addr ()
310
310
}
311
311
312
- //generateKnownHosts creates a new "known_hosts" file on a given path with a
313
- //single entry based on the given SSH server address and public key.
312
+ // generateKnownHosts creates a new "known_hosts" file on a given path with a
313
+ // single entry based on the given SSH server address and public key.
314
314
func generateKnownHosts (sshAddr , pubKeyPath , knownHostsPath string ) {
315
315
i := strings .Split (sshAddr , ":" )[0 ]
316
316
p := strings .Split (sshAddr , ":" )[1 ]
0 commit comments