2023-05-16 16:28:49 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2023-05-20 09:39:16 +02:00
|
|
|
"net/http"
|
2023-05-16 16:28:49 +02:00
|
|
|
"time"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2023-05-20 09:39:16 +02:00
|
|
|
// addr, host, port := "::", "hop.pbiernat.dev", "18181"
|
|
|
|
|
|
|
|
// lst, err := net.Listen("tcp", net.JoinHostPort(addr, port))
|
|
|
|
// if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
// }
|
|
|
|
|
|
|
|
// vmux, err := vhost.NewHTTPMuxer(lst, 3*time.Second)
|
|
|
|
// if err != nil {
|
|
|
|
// log.Fatal(err)
|
|
|
|
// }
|
|
|
|
// defer vmux.Close()
|
|
|
|
|
|
|
|
// srv := ngkrok.NewServer(addr, host, port, vmux)
|
|
|
|
// go srv.Serve()
|
|
|
|
|
|
|
|
// log.Printf("NgKrok server [%s] ready!\n", host)
|
|
|
|
|
|
|
|
// for {
|
|
|
|
// conn, err := vmux.NextError()
|
|
|
|
// fmt.Println("vmux error:", err)
|
|
|
|
// if conn != nil {
|
|
|
|
// conn.Close()
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
port := ":18181"
|
|
|
|
|
|
|
|
reverseProxy := http.HandlerFunc(func(rw http.ResponseWriter, req *http.Request) {
|
|
|
|
fmt.Printf("[reverse proxy server] received request at: %s\n", time.Now())
|
|
|
|
})
|
|
|
|
|
|
|
|
fmt.Printf("Server started at %s\n", port)
|
|
|
|
log.Fatal(http.ListenAndServe(port, reverseProxy))
|
2023-05-16 16:28:49 +02:00
|
|
|
}
|