func main() { var opts tunnelproxy.ServerOptions mc := multiconfig.New() mc.Loader = multiconfig.MultiLoader( &multiconfig.TagLoader{}, &multiconfig.EnvironmentLoader{}, &multiconfig.EnvironmentLoader{Prefix: "KONFIG_TUNNELSERVER"}, &multiconfig.FlagLoader{}, ) mc.MustLoad(&opts) server, err := tunnelproxy.NewServer(&opts) if err != nil { die(err) } k, err := tunnelproxy.NewServerKite(server, Name, Version) if err != nil { die(err) } k.Run() }
func testWithTunnelserver(t *testing.T, test func(*testing.T, *url.URL)) { // Create and start Tunnel Server. serverCfg, serverURL := Test.GenKiteConfig() if Test.NoPublic { // We start tunnel in a tunnel, so we can have more tunnels. n, err := NewNgrok() if err != nil { t.Fatalf("error creating ngrok tunnel: %s", err) } serverURL.Host, err = n.StartTCP(serverURL.Host) if err != nil { t.Fatalf("error starting ngrok tunnel: %s", err) } defer n.Stop() } baseHost := Test.HostedZone + ":" + port(serverURL.Host) Test.CleanRoute53 = append(Test.CleanRoute53, baseHost) serverOpts := &tunnelproxy.ServerOptions{ BaseVirtualHost: baseHost, HostedZone: Test.HostedZone, AccessKey: Test.AccessKey, SecretKey: Test.SecretKey, Config: serverCfg, ServerAddr: serverURL.Host, RegisterURL: serverURL.String(), TCPRangeFrom: 10000, TCPRangeTo: 50000, Log: Test.Log.New("tunnelserver"), Debug: true, Test: true, } server, err := tunnelproxy.NewServer(serverOpts) if err != nil { t.Fatalf("error creating tunnelproxy server: %s", err) } serverKite, err := tunnelproxy.NewServerKite(server, "tunnelkite", "0.0.1") if err != nil { t.Fatalf("error creating tunnelproxy server kite: %s", err) } defer serverKite.Close() go serverKite.Run() <-serverKite.ServerReadyNotify() test(t, serverURL) }