Created
April 9, 2023 15:56
-
-
Save MayankFawkes/5912150a79c0557feed4e32502ada08a to your computer and use it in GitHub Desktop.
Check if your ISP blocking your ports.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"log" | |
"net" | |
"strconv" | |
"sync" | |
) | |
const ( | |
HOST = "0.0.0.0" | |
TYPE = "tcp" | |
) | |
func start(PORT string) { | |
listen, err := net.Listen(TYPE, HOST+":"+PORT) | |
if err != nil { | |
log.Println(err) | |
return | |
} | |
// close listener | |
defer listen.Close() | |
for { | |
conn, err := listen.Accept() | |
if err != nil { | |
log.Println(err) | |
} | |
go handleIncomingRequest(conn) | |
} | |
} | |
func handleIncomingRequest(conn net.Conn) { | |
log.Println("connection accepted on", conn.LocalAddr().String()) | |
conn.Close() | |
} | |
func main() { | |
var wg sync.WaitGroup | |
wg.Add(1) | |
for i := 1; i < 65535; i++ { | |
t := strconv.Itoa(i) | |
go start(t) | |
} | |
log.Println("Server started on port 446 - 65535") | |
wg.Wait() | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import socket | |
server_ip = "YOUR IP HERE" | |
for n in range(1, 1 << 16): | |
s = socket.socket() | |
s.settimeout(3) | |
try: | |
s.connect((server_ip, n)) | |
print(f"Port - {n:<6} is Open") | |
except ConnectionRefusedError: | |
print(f"Port - {n:<6} is Blocked") | |
except socket.timeout: | |
print(f"Port - {n:<6} is Timeout") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment