Przeglądaj źródła

Control panel option to enable IRC access via onion address

Bob Mottram 9 lat temu
rodzic
commit
066a5c762b
1 zmienionych plików z 37 dodań i 3 usunięć
  1. 37
    3
      src/freedombone-controlpanel

+ 37
- 3
src/freedombone-controlpanel Wyświetl plik

@@ -49,6 +49,9 @@ VOIP_ONION_PORT=8095
49 49
 
50 50
 SSH_PORT=2222
51 51
 
52
+IRC_PORT=6697
53
+IRC_ONION_PORT=8093
54
+
52 55
 USB_DRIVE=sdb
53 56
 # get default USB from config file
54 57
 CONFIGURATION_FILE=/root/${PROJECT_NAME}.cfg
@@ -62,6 +65,9 @@ if [ -f $CONFIGURATION_FILE ]; then
62 65
     if grep -q "SSH_PORT=" $CONFIGURATION_FILE; then
63 66
         SSH_PORT=$(cat $CONFIGURATION_FILE | grep "SSH_PORT=" | awk -F '=' '{print $2}')
64 67
     fi
68
+    if grep -q "IRC_PORT=" $CONFIGURATION_FILE; then
69
+        IRC_PORT=$(cat $CONFIGURATION_FILE | grep "IRC_PORT=" | awk -F '=' '{print $2}')
70
+    fi
65 71
 fi
66 72
 
67 73
 # Mirrors settings
@@ -571,6 +577,32 @@ function change_ssh_public_key {
571 577
     esac
572 578
 }
573 579
 
580
+function irc_via_onion {
581
+    dialog --title $"IRC Server" \
582
+           --backtitle $"Freedombone Control Panel" \
583
+           --defaultno \
584
+           --yesno $"\nAccess the IRC server via an onion address?" 8 60
585
+    sel=$?
586
+    irc_onion='no'
587
+    case $sel in
588
+        0) irc_onion='yes';;
589
+        255) return;;
590
+    esac
591
+    if [[ $irc_onion == 'no' ]]; then
592
+        sed -i ":a;N;\$!ba;s/;Ports =.*/;Ports = $IRC_PORT, $IRC_ONION_PORT/1" /etc/ngircd/ngircd.conf
593
+        sed -i ":a;N;\$!ba;s/;Ports =.*/Ports = $IRC_PORT/2" /etc/ngircd/ngircd.conf
594
+        systemctl restart ngircd
595
+        dialog --title $"IRC Server" \
596
+               --msgbox $"The IRC server can now be accessed via SSL at your main domain name" 8 50
597
+    else
598
+        sed -i ":a;N;\$!ba;s/;Ports =.*/Ports = $IRC_PORT, $IRC_ONION_PORT/1" /etc/ngircd/ngircd.conf
599
+        sed -i ":a;N;\$!ba;s/;Ports =.*/Ports = $IRC_PORT/2" /etc/ngircd/ngircd.conf
600
+        systemctl restart ngircd
601
+        dialog --title $"IRC Server" \
602
+               --msgbox $"The IRC server can now be accessed via its onion address without SSL" 8 50
603
+    fi
604
+}
605
+
574 606
 function remove_user_from_mailing_list {
575 607
     select_user
576 608
     if [ ! $SELECTED_USERNAME ]; then
@@ -1612,9 +1644,10 @@ function menu_irc {
1612 1644
         trap "rm -f $data" 0 1 2 5 15
1613 1645
         dialog --backtitle $"Freedombone Control Panel" \
1614 1646
                --title $"IRC Menu" \
1615
-               --radiolist $"Choose an operation:" 13 70 3 \
1647
+               --radiolist $"Choose an operation:" 14 70 4 \
1616 1648
                1 $"Set a password for all IRC users" off \
1617
-               2 $"Exit" on 2> $data
1649
+               2 $"Access via the onion address" off \
1650
+               3 $"Exit" on 2> $data
1618 1651
         sel=$?
1619 1652
         case $sel in
1620 1653
             1) break;;
@@ -1622,7 +1655,8 @@ function menu_irc {
1622 1655
         esac
1623 1656
         case $(cat $data) in
1624 1657
             1) irc_set_global_password;;
1625
-            2) break;;
1658
+            2) irc_via_onion;;
1659
+            3) break;;
1626 1660
         esac
1627 1661
     done
1628 1662
 }