func main() { log.SetFlags(0) log.SetPrefix("webxd: ") mode := "web" if len(os.Args) > 1 { mode = os.Args[1] } switch mode { case "web": innerURL := &url.URL{Scheme: "http", Host: ":" + os.Getenv("PORT")} rp := httputil.NewSingleHostReverseProxy(innerURL) rp.Transport = new(WebsocketTransport) http.Handle("/", LogHandler{rp}) http.HandleFunc("backend.webx.io/mon/ps", ListProc) case "mon": http.HandleFunc("backend.webx.io/mon/ps", ListProc) } if os.Getenv("WEBX_VERBOSE") != "" { verbose = true } for { err := webx.DialAndServeTLS(os.Getenv("WEBX_URL"), tlsConfig, nil) if err != nil { log.Println("DialAndServe:", err) log.Println("DialAndServe:", os.Getenv("WEBX_URL")) time.Sleep(redialPause) } } }
func main() { log.SetFlags(0) log.SetPrefix("runxd: ") log.Println("starting") innerAddr := "localhost:" + os.Getenv("PORT") innerURL, err := url.Parse("http://" + innerAddr) if err != nil { log.Fatal("parse url:", err) } _, sshdConn, err = startSSHD([]byte(os.Getenv("AUTHORIZED_KEYS"))) if err != nil { log.Fatal(err) } rp := httputil.NewSingleHostReverseProxy(innerURL) rp.Transport = new(WebsocketTransport) http.Handle("/", rp) http.Handle("/sshd", OnceHandler{websocket.Handler(Proxy)}) go func() { log.Fatal(http.ListenAndServe(innerAddr, nil)) }() tlsConfig := &tls.Config{InsecureSkipVerify: true} log.Fatal(webx.DialAndServeTLS(os.Getenv("RUNX_URL"), tlsConfig, nil)) }
func main() { log.SetFlags(0) log.SetPrefix("webxd: ") innerURL := &url.URL{Scheme: "http", Host: ":" + os.Getenv("PORT")} rp := httputil.NewSingleHostReverseProxy(innerURL) rp.Transport = new(WebsocketTransport) http.Handle("/", LogHandler{rp}) if os.Getenv("WEBX_VERBOSE") != "" { verbose = true } for { err := webx.DialAndServeTLS(os.Getenv("WEBX_URL"), tlsConfig, nil) if err != nil { log.Println("DialAndServe:", err) time.Sleep(redialPause) } } }