Rewrite error messages
This commit is contained in:
parent
9d80c93177
commit
44573d328b
12
knockr.go
12
knockr.go
@ -17,13 +17,13 @@ func listener(port int, listen_func func(c net.Conn)) {
|
|||||||
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
ln, err := net.Listen("tcp", fmt.Sprintf(":%d", port))
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Errur on Listening")
|
fmt.Println("[ERR] Creating listener for Port ", port)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("Opened :", port)
|
fmt.Println("[OK ] Creating listener for Port ", port)
|
||||||
for {
|
for {
|
||||||
conn, err := ln.Accept()
|
conn, err := ln.Accept()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("Errur on Accepting")
|
fmt.Println("[ERR] Accepting on Port ", port)
|
||||||
} else {
|
} else {
|
||||||
go listen_func(conn)
|
go listen_func(conn)
|
||||||
}
|
}
|
||||||
@ -43,10 +43,10 @@ func gateway_handler(c net.Conn) {
|
|||||||
host, _, _ := net.SplitHostPort(c.RemoteAddr().String())
|
host, _, _ := net.SplitHostPort(c.RemoteAddr().String())
|
||||||
|
|
||||||
if is_whitelisted(host) {
|
if is_whitelisted(host) {
|
||||||
fmt.Println("OK: ", host)
|
fmt.Println("[OK ] Whitelisted host ", host, " connected")
|
||||||
proxy(c)
|
proxy(c)
|
||||||
} else {
|
} else {
|
||||||
fmt.Println("BLOCK: ", host)
|
fmt.Println("[BLK] Blocking host ", host)
|
||||||
}
|
}
|
||||||
c.Close()
|
c.Close()
|
||||||
}
|
}
|
||||||
@ -70,7 +70,7 @@ func is_whitelisted(addr string) bool {
|
|||||||
func proxy(c net.Conn) {
|
func proxy(c net.Conn) {
|
||||||
ln, err := net.Dial("tcp", "ip.darknebu.la:443")
|
ln, err := net.Dial("tcp", "ip.darknebu.la:443")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println("ERR proxy")
|
fmt.Println("[ERR] Proxy connection to server failed")
|
||||||
} else {
|
} else {
|
||||||
go io.Copy(c, ln)
|
go io.Copy(c, ln)
|
||||||
io.Copy(ln, c)
|
io.Copy(ln, c)
|
||||||
|
Loading…
Reference in New Issue
Block a user