Rewrite error messages

This commit is contained in:
maride 2017-09-27 23:08:23 +02:00
parent 9d80c93177
commit 44573d328b

View File

@ -17,13 +17,13 @@ func listener(port int, listen_func func(c net.Conn)) {
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
if err != nil {
fmt.Println("Errur on Listening")
fmt.Println("[ERR] Creating listener for Port ", port)
} else {
fmt.Println("Opened :", port)
fmt.Println("[OK ] Creating listener for Port ", port)
for {
conn, err := ln.Accept()
if err != nil {
fmt.Println("Errur on Accepting")
fmt.Println("[ERR] Accepting on Port ", port)
} else {
go listen_func(conn)
}
@ -43,10 +43,10 @@ func gateway_handler(c net.Conn) {
host, _, _ := net.SplitHostPort(c.RemoteAddr().String())
if is_whitelisted(host) {
fmt.Println("OK: ", host)
fmt.Println("[OK ] Whitelisted host ", host, " connected")
proxy(c)
} else {
fmt.Println("BLOCK: ", host)
fmt.Println("[BLK] Blocking host ", host)
}
c.Close()
}
@ -70,7 +70,7 @@ func is_whitelisted(addr string) bool {
func proxy(c net.Conn) {
ln, err := net.Dial("tcp", "ip.darknebu.la:443")
if err != nil {
fmt.Println("ERR proxy")
fmt.Println("[ERR] Proxy connection to server failed")
} else {
go io.Copy(c, ln)
io.Copy(ln, c)