Skip to content

Instantly share code, notes, and snippets.

View mrThe's full-sized avatar
🐓

mr.The mrThe

🐓
View GitHub Profile
@mrThe
mrThe / port_check.rb
Created January 23, 2017 10:11
Ruby #port_open?
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)
@mrThe
mrThe / ip-up.sh
Last active May 31, 2017 18:18
Sanctions address /etc/ppp/ip-up
# 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
@mrThe
mrThe / port_open.rb
Created June 19, 2019 10:43
Ruby check if port_open?
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)