in reply to Module name: PDL::WebSocket?
Edit to add: actually, the user-facing lightningmaps protocol is revealed by reading the JS (see https://www.lightningmaps.org/min/index.php?f=js/realtime.js&1687455813), which isn't overly minified, and with text-search for data.ws. shows what's being sent and received. The blitzortung JS on the other hand goes all in on minification, including actually obfuscating var names with randomised hex numbers.use strict; use warnings; use Mojo::UserAgent; use Mojo::JSON qw(decode_json); use Encode qw(encode); my $ua = Mojo::UserAgent->new; $ua->websocket("wss://ws1.blitzortung.org/" => sub { my ($ua, $tx) = @ +_; print "WebSocket handshake failed!\n" and return unless $tx->is_webs +ocket; $tx->on(message => sub { my ($tx, $chars) = @_; $chars = blitz_decode($chars); my $bytes = encode('UTF-8', $chars, Encode::FB_CROAK); my $hash = decode_json $bytes; use Data::Dumper; print "message ", Dumper $hash; }); $tx->send({json=>{a=>111}}); }); Mojo::IOLoop->start unless Mojo::IOLoop->is_running; # code from https://github.com/mrk-its/homeassistant-blitzortung/issue +s/74 sub blitz_decode { my ($data) = @_; my %e; my @d = split //, $data; my @g = my $f = my $c = $d[0]; my $o = 256; for my $ind (1..$#d) { my $ord = ord($d[$ind]); my $str = $ord < 256 ? $d[$ind] : exists $e{$ord} ? $e{$ord} : $f +. $c; push @g, $str; $c = substr $str, 0, 1; $e{$o++} = $f . $c; $f = $str; } join('', @g); }
|
---|