robacarp / icmp.cr Goto Github PK
View Code? Open in Web Editor NEWA terse implementation of ICMP Ping in Crystal
License: MIT License
A terse implementation of ICMP Ping in Crystal
License: MIT License
Hi,
I get the following when I try to run the example in the readme. I'm using crystal 0.32.1 on Ubuntu Server 16.04 LTS.
Unhandled exception: Arithmetic overflow (OverflowError)
from lib/icmp/src/icmp/packet.cr:0:16 in 'calculate_checksum'
from lib/icmp/src/icmp/request.cr:29:19 in 'initialize'
from lib/icmp/src/icmp/request.cr:14:5 in 'new'
from lib/icmp/src/icmp.cr:54:9 in '__crystal_main'
from /usr/share/crystal/src/crystal/main.cr:97:5 in 'main_user_code'
from /usr/share/crystal/src/crystal/main.cr:86:7 in 'main'
from /usr/share/crystal/src/crystal/main.cr:106:3 in 'main'
from __libc_start_main
from _start
from ???
Thanks,
-G
Cool library, I enjoy using it.
When sending request on dead (aka, ping failed) address, the command just hangs.
https://github.com/robacarp/icmp.cr/blob/master/src/icmp/request.cr
require "icmp"
HOST = "227.227.227.217"
ICMP::Ping.new(HOST).ping.["success"]
ICMP::Ping.new(HOST).ping(count:1)["success"]
Yielding it does not fix the issue.
Cheers
Nice library! Was worried I'd have to code ping myself. :-)
I can't get it to work on Linux unless I'm root, even though I think I have /proc/sys/net/ipv4/ping_group_range set correctly. Any idea what might be wrong?
$ cat /proc/sys/net/ipv4/ping_group_range
0 2147483647
$ uname -r
4.15.3-2-ARCH
$ id
uid=1000(fraser) gid=1000(fraser) groups=1000(fraser),10(wheel),14(uucp),100(users),614(adbusers)
$ crystal run test.cr
failed to create socket:: Operation not permitted (Errno)
from /usr/lib/crystal/socket.cr:0:5 in 'initialize'
from /usr/lib/crystal/socket.cr:69:3 in 'initialize'
from IPSocket
from lib/icmp/src/icmp.cr:44:9 in 'initialize'
from lib/icmp/src/icmp.cr:26:5 in 'new'
from test.cr:16:14 in '__crystal_main'
from /usr/lib/crystal/crystal/main.cr:11:3 in '_crystal_main'
from /usr/lib/crystal/crystal/main.cr:112:5 in 'main_user_code'
from /usr/lib/crystal/crystal/main.cr:101:7 in 'main'
from /usr/lib/crystal/crystal/main.cr:135:3 in 'main'
from __libc_start_main
from _start
from ???
$ sudo crystal run test.cr
0 valid_response took 2ms
1 valid_response took 1ms
2 valid_response took 1ms
The code is just your example modified with a local IP address (although 8.8.8.8 obviously doesn't work either):
require "icmp"
statistics = ICMP::Ping.new("192.168.0.5").ping(count: 3) do |request|
puts "#{request.sequence} #{request.status} took #{request.roundtrip_time}ms"
end
p statistics
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.