浏览代码

Control panel option to enable IRC access via onion address

Bob Mottram 9 年前
父节点
当前提交
066a5c762b
共有 1 个文件被更改,包括 37 次插入3 次删除
  1. 37
    3
      src/freedombone-controlpanel

+ 37
- 3
src/freedombone-controlpanel 查看文件

49
 
49
 
50
 SSH_PORT=2222
50
 SSH_PORT=2222
51
 
51
 
52
+IRC_PORT=6697
53
+IRC_ONION_PORT=8093
54
+
52
 USB_DRIVE=sdb
55
 USB_DRIVE=sdb
53
 # get default USB from config file
56
 # get default USB from config file
54
 CONFIGURATION_FILE=/root/${PROJECT_NAME}.cfg
57
 CONFIGURATION_FILE=/root/${PROJECT_NAME}.cfg
62
     if grep -q "SSH_PORT=" $CONFIGURATION_FILE; then
65
     if grep -q "SSH_PORT=" $CONFIGURATION_FILE; then
63
         SSH_PORT=$(cat $CONFIGURATION_FILE | grep "SSH_PORT=" | awk -F '=' '{print $2}')
66
         SSH_PORT=$(cat $CONFIGURATION_FILE | grep "SSH_PORT=" | awk -F '=' '{print $2}')
64
     fi
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
 fi
71
 fi
66
 
72
 
67
 # Mirrors settings
73
 # Mirrors settings
571
     esac
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
 function remove_user_from_mailing_list {
606
 function remove_user_from_mailing_list {
575
     select_user
607
     select_user
576
     if [ ! $SELECTED_USERNAME ]; then
608
     if [ ! $SELECTED_USERNAME ]; then
1612
         trap "rm -f $data" 0 1 2 5 15
1644
         trap "rm -f $data" 0 1 2 5 15
1613
         dialog --backtitle $"Freedombone Control Panel" \
1645
         dialog --backtitle $"Freedombone Control Panel" \
1614
                --title $"IRC Menu" \
1646
                --title $"IRC Menu" \
1615
-               --radiolist $"Choose an operation:" 13 70 3 \
1647
+               --radiolist $"Choose an operation:" 14 70 4 \
1616
                1 $"Set a password for all IRC users" off \
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
         sel=$?
1651
         sel=$?
1619
         case $sel in
1652
         case $sel in
1620
             1) break;;
1653
             1) break;;
1622
         esac
1655
         esac
1623
         case $(cat $data) in
1656
         case $(cat $data) in
1624
             1) irc_set_global_password;;
1657
             1) irc_set_global_password;;
1625
-            2) break;;
1658
+            2) irc_via_onion;;
1659
+            3) break;;
1626
         esac
1660
         esac
1627
     done
1661
     done
1628
 }
1662
 }