32 lines
639 B
Go

package main
import (
"fmt"
"github.com/sduden/simpleproxy"
"os"
)
// simpleproxy is a simple proxy server.
// the first argument passed to the program is the address of the server to proxy to.
// the second argument is the address to listen on.
// if not specified, listens on 0.0.0.0:8080
func main() {
if len(os.Args) < 2 {
fmt.Printf("Usage: %s <server> [listen]\n", os.Args[0])
os.Exit(1)
}
server := os.Args[1]
listen := ":8080"
if len(os.Args) > 2 {
listen = os.Args[2]
}
fmt.Printf("Listening on %s, proxying to %s\n", listen, server)
proxy := simpleproxy.NewProxy(listen, server)
proxy.ListenAndServe()
}