This file contains 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
def port_open?(host, port, timeout = 5) | |
addr = Socket.getaddrinfo(host, nil) | |
sockaddr = Socket.pack_sockaddr_in(port, addr[0][3]) | |
Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0).tap do |socket| | |
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) | |
begin | |
# Initiate the socket connection in the background. If it doesn't fail | |
# immediatelyit will raise an IO::WaitWritable (Errno::EINPROGRESS) |
This file contains 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
# sudo touch /etc/ppp/ip-up | |
# sudo chmod 755 /etc/ppp/ip-up | |
# File content: | |
#!/bin/sh | |
# https://git.sysalex.com/snippets/7 | |
# https://zaborona.help/ips.txt |
This file contains 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
def port_open?(host, port, timeout = 5) | |
addr = Socket.getaddrinfo(host, nil) | |
sockaddr = Socket.pack_sockaddr_in(port, addr[0][3]) | |
Socket.new(Socket.const_get(addr[0][0]), Socket::SOCK_STREAM, 0).tap do |socket| | |
socket.setsockopt(Socket::IPPROTO_TCP, Socket::TCP_NODELAY, 1) | |
begin | |
# Initiate the socket connection in the background. If it doesn't fail | |
# immediatelyit will raise an IO::WaitWritable (Errno::EINPROGRESS) |
OlderNewer