summaryrefslogtreecommitdiffstats
path: root/tool
diff options
context:
space:
mode:
authorwritecode <wri@tec.ode>2019-05-06 23:18:04 +0000
committerwritecode <wri@tec.ode>2019-05-06 23:18:04 +0000
commit6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2 (patch)
treec5af0bc69ae49b0929fcb05a3348d5927c838934 /tool
parent276b8a0169f245ccc4271a323cd296f776329aac (diff)
downloadcloudflare-tor-6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2.tar
cloudflare-tor-6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2.tar.gz
cloudflare-tor-6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2.tar.lz
cloudflare-tor-6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2.tar.xz
cloudflare-tor-6d4a595b292e799c7ab22a2f7c1b808d2f7d96f2.zip
Update 'tool/irssi_cf_alturl.pl'
Diffstat (limited to 'tool')
-rw-r--r--tool/irssi_cf_alturl.pl69
1 files changed, 53 insertions, 16 deletions
diff --git a/tool/irssi_cf_alturl.pl b/tool/irssi_cf_alturl.pl
index b3218889..583a2213 100644
--- a/tool/irssi_cf_alturl.pl
+++ b/tool/irssi_cf_alturl.pl
@@ -8,8 +8,10 @@
# /set cflarealt_debug <on|off> -- (off) if you have a problem try turning this on to debug
# /set cflarealt_send2channel <on|off> -- (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 <on|off> -- (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 <on|off> -- (off) set it 'on' to use .onion
#
# /set cflarealt_localdbpath <"string to path"> -- () '/path/database/split/'
# /set cflarealt_uselocaldb <on|off> -- (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;
}
}
}