diff --git a/tool/irssi_cf_alturl.pl b/tool/irssi_cf_alturl.pl index b321888..583a221 100644 --- a/tool/irssi_cf_alturl.pl +++ b/tool/irssi_cf_alturl.pl @@ -8,8 +8,10 @@ # /set cflarealt_debug -- (off) if you have a problem try turning this on to debug # /set cflarealt_send2channel -- (off) send the converted URL publicly to everyone in your channels # /set cflarealt_channels <"#channel1, #channel2, etc"> -- Channels to automatically convert. Empty Defaults to all +# # /set cflarealt_shorturl_activate -- (off) set it 'on' to use shortner # /set cflarealt_shorturl_min <40> -- (40) How long a url has to be to trigger automatic url shortening +# /set cflarealt_shorturl_useonion -- (off) set it 'on' to use .onion # # /set cflarealt_localdbpath <"string to path"> -- () '/path/database/split/' # /set cflarealt_uselocaldb -- (off) if 'on', please set path to local database (or the script will die) @@ -40,8 +42,8 @@ use LWP::Simple; use LWP::UserAgent; my ( - $cfg_minurllen, $cfg_send2chan, $cfg_useshort, $cfg_isdebug, - $cfg_uselocaldb, $cfg_localdbpath, $cfg_chanlist + $cfg_minurllen, $cfg_send2chan, $cfg_useshort, $cfg_shortonion, + $cfg_isdebug, $cfg_uselocaldb, $cfg_localdbpath, $cfg_chanlist ); my ( $cfg_printurl, $cfg_donotsendurl ); my @cached = (); @@ -59,6 +61,12 @@ sub setuphandler { $cfg_useshort = 1; } + Irssi::settings_add_bool( "cflarealt", "cflarealt_shorturl_useonion", 0 ); + if ( Irssi::settings_get_bool("cflarealt_shorturl_useonion") ) { + print "cflarealt: URL onion enabled"; + $cfg_shortonion = 1; + } + Irssi::settings_add_str( "cflarealt", "cflarealt_channels", "" ); $cfg_chanlist = Irssi::settings_get_str("cflarealt_channels"); if ($cfg_chanlist) { @@ -218,9 +226,13 @@ sub GotUrl { else { deb("$target Asking API about $fqdn"); $answer = ''; - $url = 'https://searxes.danwin1210.me/collab/open/ismitm.php?f='.$fqdn; + $url = + 'https://searxes.danwin1210.me/collab/open/ismitm.php?f=' + . $fqdn; $browser = LWP::UserAgent->new; - $browser->agent("Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0"); + $browser->agent( +"Mozilla/5.0 (Windows NT 6.1; rv:60.0) Gecko/20100101 Firefox/60.0" + ); $response = $browser->get($url); $answer = $response->content; if ( $answer eq '[true,true]' ) { @@ -234,20 +246,45 @@ sub GotUrl { ## ACT2: Short URL __if__ enabled and long if ( $cfg_useshort == 1 ) { if ( length($myurl) > $cfg_minurllen ) { - deb("$target Creating Short URL for $myurl"); - $url = 'https://ux.nu/api/short?format=plain&url='.$myurl; - $browser = LWP::UserAgent->new; - $browser->agent("cloudflare-tor (Thank you for your service)"); - $response = $browser->get($url); - $answer = $response->content; - if ( index( $answer, 'https://ux.nu/' ) == 0 ) { - if ( $mytype eq '' ) { - $mytype = '^B^C7[Short]^O '; + if ( $cfg_shortonion == 1 ) { + deb("$target Creating Short Onion for $myurl"); + $url = 'https://url.danwin1210.me/?i=new&url=' . $myurl; + $browser = LWP::UserAgent->new; + $browser->agent("cloudflare-tor"); + $response = $browser->get($url); + $answer = $response->content; + if ( + index( $answer, + 'http://dt2tq5y2ccowebjo.onion/?i=' ) == 0 + ) + { + if ( $mytype eq '' ) { + $mytype = '^B^C7[Onion]^O '; + } + else { + $mytype = '^B^C2[Onion,Archive]^O '; + } + $myurl = $answer; } - else { - $mytype = '^B^C2[Short,Archive]^O '; + } + else { + deb("$target Creating Short URL for $myurl"); + $url = + 'https://ux.nu/api/short?format=plain&url=' . $myurl; + $browser = LWP::UserAgent->new; + $browser->agent( + "cloudflare-tor (Thank you for your service)"); + $response = $browser->get($url); + $answer = $response->content; + if ( index( $answer, 'https://ux.nu/' ) == 0 ) { + if ( $mytype eq '' ) { + $mytype = '^B^C7[Short]^O '; + } + else { + $mytype = '^B^C2[Short,Archive]^O '; + } + $myurl = $answer; } - $myurl = $answer; } } }