Difference between revisions of "ZNC"

From Amahi Wiki
Jump to: navigation, search
 
(29 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category: Apps]]
 
 
tags: IRC Chat mIRC bounce Chatzilla server<br><br>
 
tags: IRC Chat mIRC bounce Chatzilla server<br><br>
[http://www.amahi.org/apps/znc ZNC] is an IRC bounce with many advanced features such as a built-in web interface, persistent connection (detaching), multiple users, per channel playback buffer, SSL, IPv6, transparent DCC bouncing, and c++ module support, to name a few.
+
[http://www.amahi.org/apps/znc ZNC] is an Internet Relay Chat (IRC) network bouncer or BNC. It can detach the client from the actual IRC server, and also from selected channels. Multiple clients from different locations can connect to a single ZNC account simultaneously and therefore appear under the same nickname on IRC. It supports Secure Sockets Layer (SSL) secured connections and IPv6.
  
 
== About ZNC in Amahi ==
 
== About ZNC in Amahi ==
* Currently '''LIVE''' in Amahi.
+
* Currently '''BETA''' for Amahi 7.
 
* The application makes use of your HDA first admin user.  To log in to the web interface, enter that user name and the password is ''admin''.  You can change the password once logged in to anything you desire.
 
* The application makes use of your HDA first admin user.  To log in to the web interface, enter that user name and the password is ''admin''.  You can change the password once logged in to anything you desire.
* Once the application is installed, you are automatically connected to the IRC for the server '''irc.freenode.net'''.  This setting can be turned off via the web interface if you do not want to autoconnect when ZNC is started.
 
 
* ZNC appears in the '''Servers''' tab so you can stop, start, and restart as needed.
 
* ZNC appears in the '''Servers''' tab so you can stop, start, and restart as needed.
 +
*  There is a [http://wiki.znc.in/FAQ FAQ] on the ZNC web site which may help with  common questions.
  
== SSL Configuration ==
+
== Initial Configuration ==
To enable SSL support, some manual configuration must be done (Required '''znc.pem''' certificate is pre-installed; it can be regenerated by following [[ZNC#Generating_a_SSL_Certificate|Generate a SSL Certificate]]).
+
There are a few steps you need to complete before ZNC is ready.
 
+
# Log into the web interface using credentials as noted in the Special Instructions on the Applications Installed tabExpand the ZNC app and you will see them displayed.
* As '''root''' user, install one dependency:
+
# Once logged in, select User Settings from the menu on the left.
yum -y install mod_ssl
+
# To be continued...
<!--* Add the following line to the end of '''''/etc/httpd/conf/httpd.conf''''' if it does not already exist:
 
NameVirtualHost *:443-->
 
* Change the line in '''''/etc/httpd/conf.d/####-znc.conf''''' to read (replace #### with the number in your file name):
 
RedirectPermanent / <nowiki>https://znc:26244</nowiki>
 
* Restart the web server:
 
service httpd restart
 
* Modify the line in '''''/home/username/.znc/config/znc.conf''''' to read:
 
  Listener4 = +26244
 
 
 
* Restart ZNC:
 
service znc restart
 
* Access the web console via '''<nowiki>https://znc:26244</nowiki>'''
 
* All connections with IRC clients will be SSL.  When you add new servers, ensure you precede the port number with a '''+'''.  The default server on install is already set for SSL communication.
 
 
 
 
 
'''NOTE:'''  See [http://en.znc.in/wiki/Configuration ZNC Configuration] for more guidance on customization.
 
 
 
== Generating a SSL Certificate ==
 
You can use the following openssl commands to generate a certificate:
 
openssl req -nodes -newkey rsa:2048 -keyout znc.key -x509 -days 365 -out znc.crt
 
cat znc.crt znc.key > znc.pem
 
Copy this file to your '''/home/username/.znc''' directory (replace ''username'' with your first admin user name) and restart ZNC:
 
service znc restart
 
 
 
 
 
'''NOTE:'''  See [http://wiki.znc.in/Cert ZNC Cert] for more guidance on certificates.
 
 
 
== Backup Personal Settings ==
 
You can have your setting automatically backed up or do it manually.  This script will email them to you as a compressed file.
 
* Install a few dependencies:
 
yum install p7zip mailx
 
* Create <b>znc-backup.sh</b> and place it in /var/hda/web-apps/znc/html directory (ensure you change the USER as noted below):
 
<pre>
 
vi /var/hda/web-apps/znc/html/znc-backup.sh
 
</pre>
 
<pre>
 
#!/bin/bash
 
### You can change this if you want
 
USER=`/var/hda/platform/html/script/first-admin`
 
MAILADRESSE1=root
 
YOUREHOST=localhost
 
### Facultatif change :
 
DIR=/home/$USER/.znc
 
TAR_PATH=`whereis tar | cut -d ' ' -f 2`
 
p7zip_PATH=`whereis 7za | cut -d ' ' -f 2`
 
SendEmail_PATH=`whereis mailx | cut -d ' ' -f 2`
 
DATEI1=$(date +%Y-%m-%d)_znc_backup.tar
 
DATEI2=$(date +%Y-%m-%d)_znc_backup.tar.7z
 
DATUM=$(date +%Y-%m-%d)
 
sevenzp="a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -mhe=on"
 
### no Change after here
 
if [ ! -d "$DIR" ]; then echo "You MUST change DIR variable. TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup";  exit 0; fi
 
if [ ! -x "$TAR_PATH" ]; then echo "You MUST change TAR_PATH variable. Or install TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 
if [ ! -x "$p7zip_PATH" ]; then echo "You MUST change p7zip_PATH variable. Or install p7zip. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 
if [ ! -x "$SendEmail_PATH" ]; then echo "You MUST change SendEmail_PATH variable. Or install SendEmail. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 
$TAR_PATH -cvf $DATEI1 $DIR
 
$p7zip_PATH $sevenzp $DATEI2 $DATEI1
 
echo ZNC Backup from $DATUM | $SendEmail_PATH -r $USER@$YOUREHOST -s ZNC-Backup-$DATUM -a $DATEI2 $MAILADRESSE1
 
rm -f $DATEI1 $DATEI2
 
</pre>
 
* Make script executable
 
chmod 755 /var/hda/web-apps/znc/html/znc-backup.sh
 
* To run manually, execute the script from the /var/hda/web-apps/znc/html directory
 
./znc-backup.sh
 
* Install a cron job as your First Admin User, not root and insert the following text:
 
<pre>crontab -e</pre>
 
<pre>40 0  * * 5 /var/hda/web-apps/znc/html/znc-backup.sh >/dev/null 2>&1</pre>
 
<blockquote><b>NOTE:</b>  This will run on Fri at 00:40 AM, but you can change to meet your needs.</blockquote>
 
  
 
== IRC Client Setup ==
 
== IRC Client Setup ==
Line 141: Line 72:
 
=== Chatzilla (FireFox Add-on) ===
 
=== Chatzilla (FireFox Add-on) ===
 
After installation of Chatzilla Add-on you can enter the following in your browsers address bar:
 
After installation of Chatzilla Add-on you can enter the following in your browsers address bar:
  {{Link|Link=irc://<YouHdaIp>:26244/<channel>/?pass=<ZncUser>:<ZncUserPass>}}
+
  irc://<YouHdaIp>:26244/<channel>/?pass=<ZncUser>:<ZncUserPass>
 
or
 
or
  {{Link|Link=irc://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>}}
+
  irc://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>
 
or SSL
 
or SSL
  {{Link|Link=ircs://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>}}
+
  ircs://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>
  
 
== Client Commands ==
 
== Client Commands ==
Line 315: Line 246:
  
 
'''NOTE:'''  Go [http://en.znc.in/wiki/Modules here] for guidance on how to use ZNC modules.
 
'''NOTE:'''  Go [http://en.znc.in/wiki/Modules here] for guidance on how to use ZNC modules.
 +
 +
== SSL Configuration ==
 +
To enable SSL support, some manual configuration must be done (Required '''znc.pem''' certificate is pre-installed; it can be regenerated by following [[ZNC#Generating_a_SSL_Certificate|Generate a SSL Certificate]]).
 +
 +
* As '''root''' user, install one dependency:
 +
yum -y install mod_ssl
 +
<!--* Add the following line to the end of '''''/etc/httpd/conf/httpd.conf''''' if it does not already exist:
 +
NameVirtualHost *:443-->
 +
* Change the line in '''''/etc/httpd/conf.d/####-znc.conf''''' to read (replace #### with the number in your file name):
 +
RedirectPermanent / <nowiki>https://znc:26244</nowiki>
 +
* Restart the web server:
 +
systemctl restart httpd.service
 +
* Modify the line in '''''/home/username/.znc/config/znc.conf''''' to read:
 +
Listener4 = +26244
 +
 +
* Restart ZNC:
 +
systemctl restart znc.service
 +
* Access the web console via '''<nowiki>https://znc:26244</nowiki>'''
 +
* All connections with IRC clients will be SSL.  When you add new servers, ensure you precede the port number with a '''+''' (the pre-installed server is already set for SSL communication).
 +
 +
 +
'''NOTE:'''  See [http://en.znc.in/wiki/Configuration ZNC Configuration] for more guidance on customization.
 +
 +
== Generating a SSL Certificate ==
 +
You can use the following openssl commands to generate a certificate:
 +
openssl req -nodes -newkey rsa:2048 -keyout znc.key -x509 -days 365 -out znc.crt
 +
cat znc.crt znc.key > znc.pem
 +
Copy this file to your '''/home/username/.znc''' directory (replace ''username'' with your first admin user name) and restart ZNC:
 +
systemctl restart znc.service
 +
 +
 +
'''NOTE:'''  See [http://wiki.znc.in/Cert ZNC Cert] for more guidance on certificates.
 +
 +
== Backup Personal Settings ==
 +
You can have your setting automatically backed up or do it manually.  This script will email them to you as a compressed file. 
 +
* Install a few dependencies:
 +
yum install p7zip mailx
 +
* Create <b>znc-backup.sh</b> and place it in /var/hda/web-apps/znc/html directory (ensure you change the USER as noted below):
 +
<pre>
 +
vi /var/hda/web-apps/znc/html/znc-backup.sh
 +
</pre>
 +
<pre>
 +
#!/bin/bash
 +
### You can change this if you want
 +
USER=`/var/hda/platform/html/script/first-admin`
 +
MAILADRESSE1=root
 +
YOUREHOST=localhost
 +
### Facultatif change :
 +
DIR=/home/$USER/.znc
 +
TAR_PATH=`whereis tar | cut -d ' ' -f 2`
 +
p7zip_PATH=`whereis 7za | cut -d ' ' -f 2`
 +
SendEmail_PATH=`whereis mailx | cut -d ' ' -f 2`
 +
DATEI1=$(date +%Y-%m-%d)_znc_backup.tar
 +
DATEI2=$(date +%Y-%m-%d)_znc_backup.tar.7z
 +
DATUM=$(date +%Y-%m-%d)
 +
sevenzp="a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -mhe=on"
 +
### no Change after here
 +
if [ ! -d "$DIR" ]; then echo "You MUST change DIR variable. TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup";  exit 0; fi
 +
if [ ! -x "$TAR_PATH" ]; then echo "You MUST change TAR_PATH variable. Or install TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 +
if [ ! -x "$p7zip_PATH" ]; then echo "You MUST change p7zip_PATH variable. Or install p7zip. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 +
if [ ! -x "$SendEmail_PATH" ]; then echo "You MUST change SendEmail_PATH variable. Or install SendEmail. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
 +
$TAR_PATH -cvf $DATEI1 $DIR
 +
$p7zip_PATH $sevenzp $DATEI2 $DATEI1
 +
echo ZNC Backup from $DATUM | $SendEmail_PATH -r $USER@$YOUREHOST -s ZNC-Backup-$DATUM -a $DATEI2 $MAILADRESSE1
 +
rm -f $DATEI1 $DATEI2
 +
</pre>
 +
* Make script executable
 +
chmod 755 /var/hda/web-apps/znc/html/znc-backup.sh
 +
* To run manually, execute the script from the /var/hda/web-apps/znc/html directory
 +
./znc-backup.sh
 +
* Install a cron job as your First Admin User, not root and insert the following text:
 +
<pre>crontab -e</pre>
 +
<pre>40 0  * * 5 /var/hda/web-apps/znc/html/znc-backup.sh >/dev/null 2>&1</pre>
 +
<blockquote><b>NOTE:</b>  This will run on Fri at 00:40 AM, but you can change to meet your needs.</blockquote>
  
 
== Troubleshooting ==
 
== Troubleshooting ==
Line 323: Line 328:
 
You could try using the IP address of the server you are trying to connect to. For '''''chat.freenode.net''''' this IP is:
 
You could try using the IP address of the server you are trying to connect to. For '''''chat.freenode.net''''' this IP is:
 
'''''140.211.166.3'''''
 
'''''140.211.166.3'''''
* Go to your [http://znc:26244 ZNC webadmin page]
+
* Go to your ZNC webadmin page
 
* Login using your username and password
 
* Login using your username and password
 
* Click on "Your Settings"  
 
* Click on "Your Settings"  
Line 331: Line 336:
 
=== Install Fails ===
 
=== Install Fails ===
 
If you have installed ZNC multiple times without success, perform the following as '''root''' user:
 
If you have installed ZNC multiple times without success, perform the following as '''root''' user:
{{Code|yum -y erase znc*}}
+
yum -y erase znc*
 
* Once the RPMs have been removed, perform install.
 
* Once the RPMs have been removed, perform install.
 
* Check ''/var/log/amahi-app-installer.log'' for details.
 
* Check ''/var/log/amahi-app-installer.log'' for details.
 +
<br>
 +
[[Category: Apps]]

Latest revision as of 21:54, 3 March 2016

tags: IRC Chat mIRC bounce Chatzilla server

ZNC is an Internet Relay Chat (IRC) network bouncer or BNC. It can detach the client from the actual IRC server, and also from selected channels. Multiple clients from different locations can connect to a single ZNC account simultaneously and therefore appear under the same nickname on IRC. It supports Secure Sockets Layer (SSL) secured connections and IPv6.

About ZNC in Amahi

  • Currently BETA for Amahi 7.
  • The application makes use of your HDA first admin user. To log in to the web interface, enter that user name and the password is admin. You can change the password once logged in to anything you desire.
  • ZNC appears in the Servers tab so you can stop, start, and restart as needed.
  • There is a FAQ on the ZNC web site which may help with common questions.

Initial Configuration

There are a few steps you need to complete before ZNC is ready.

  1. Log into the web interface using credentials as noted in the Special Instructions on the Applications Installed tab. Expand the ZNC app and you will see them displayed.
  2. Once logged in, select User Settings from the menu on the left.
  3. To be continued...

IRC Client Setup

mIRC

  • When using the mIRC client you will need to connect to ZNC using the following command:
/server -m <yourHdaIp> -p 26244 -g gZNC -w <username>:<password> -d ZNC
Option Description
<yourHdaIp> The ip address of the HDA where you installed ZNC
<username> Username that's configured to connect to a channel
<password> Password for the username that's configured to connect to a channel


  • When using mIRC in Windows, go to the options page. Select Server and choose Add. The following window will open:

Mirc-settings-znc.jpg


Option Value
Description ZNC
IRC Server HDA IP
Port 26244
Group ZNC
Password ZNC <username>:<password>


Chatzilla (FireFox Add-on)

After installation of Chatzilla Add-on you can enter the following in your browsers address bar:

irc://<YouHdaIp>:26244/<channel>/?pass=<ZncUser>:<ZncUserPass>

or

irc://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>

or SSL

ircs://<YourHdaIp>:26244/,needpass?pass=<ZncUser>:<ZncUserPass>

Client Commands

Commands are given to ZNC by messaging the virtual user *status. Likewise, modules are communicated to by messaging *modname as well. Alternatively you can use /znc command instead of /msg *status command and /znc *module command instead of /msg *module command.

Command Arguments Description
Version Prints which version of znc this is
ListDCCs List all active DCCs
ListMods List all loaded modules
ListAvailMods List all available modules
ListChans List all channels
ListNicks <#chan> List all nicks on a channel
ListServers List all servers
AddServer <host> [[+]port] [pass] Add a server to the list
RemServer <host> Remove a server from the list
Enablechan <#chan> Enable the channel
Detach <#chan> Detach from the channel
Topics Show topics in all channels
PlayBuffer <#chan> Play back the buffer for a given channel
ClearBuffer <#chan> Clear the buffer for a given channel
ClearAllChannelBuffers Clear the channel buffers
SetBuffer <#chan> [linecount] Set the buffer count for a channel
SetVHost <vhost (ip preferred)> Set the VHost for this connection
ClearVHost Clear the VHost for this connection
Jump Jump to the next server in the list
Disconnect Disconnect from IRC
Connect Reconnect to IRC
Send <nick> <file> Send a shell file to a nick on IRC
Get <file> Send a shell file to yourself
LoadMod <module> Load a module
UnloadMod <module> Unload a module
ReloadMod <module> Reload a module
ShowMOTD Show the message of the day
SetMOTD <Message> Set the message of the day
AddMOTD <Message> Append <Message> to MOTD
ClearMOTD Clear the MOTD
Rehash Reload znc.conf from disk
SaveConfig Save the current settings to disk
ListUsers List all users/clients connected to znc
ListClients [User] List all clients connected to your znc user
Traffic Show basic traffic stats for all znc users
Uptime Show how long ZNC is already running
Broadcast [message] Broadcast a message to all users
Shutdown [message] Shutdown znc completely
Restart [message] Restarts znc


NOTE: Go here for guidance on how to use ZNC modules.

SSL Configuration

To enable SSL support, some manual configuration must be done (Required znc.pem certificate is pre-installed; it can be regenerated by following Generate a SSL Certificate).

  • As root user, install one dependency:
yum -y install mod_ssl
  • Change the line in /etc/httpd/conf.d/####-znc.conf to read (replace #### with the number in your file name):
RedirectPermanent / https://znc:26244
  • Restart the web server:
systemctl restart httpd.service
  • Modify the line in /home/username/.znc/config/znc.conf to read:
Listener4 = +26244
  • Restart ZNC:
systemctl restart znc.service
  • Access the web console via https://znc:26244
  • All connections with IRC clients will be SSL. When you add new servers, ensure you precede the port number with a + (the pre-installed server is already set for SSL communication).


NOTE: See ZNC Configuration for more guidance on customization.

Generating a SSL Certificate

You can use the following openssl commands to generate a certificate:

openssl req -nodes -newkey rsa:2048 -keyout znc.key -x509 -days 365 -out znc.crt

cat znc.crt znc.key > znc.pem Copy this file to your /home/username/.znc directory (replace username with your first admin user name) and restart ZNC:

systemctl restart znc.service


NOTE: See ZNC Cert for more guidance on certificates.

Backup Personal Settings

You can have your setting automatically backed up or do it manually. This script will email them to you as a compressed file.

  • Install a few dependencies:
yum install p7zip mailx
  • Create znc-backup.sh and place it in /var/hda/web-apps/znc/html directory (ensure you change the USER as noted below):
vi /var/hda/web-apps/znc/html/znc-backup.sh
#!/bin/bash
### You can change this if you want
USER=`/var/hda/platform/html/script/first-admin`
MAILADRESSE1=root
YOUREHOST=localhost
### Facultatif change :
DIR=/home/$USER/.znc
TAR_PATH=`whereis tar | cut -d ' ' -f 2`
p7zip_PATH=`whereis 7za | cut -d ' ' -f 2`
SendEmail_PATH=`whereis mailx | cut -d ' ' -f 2`
DATEI1=$(date +%Y-%m-%d)_znc_backup.tar
DATEI2=$(date +%Y-%m-%d)_znc_backup.tar.7z
DATUM=$(date +%Y-%m-%d)
sevenzp="a -t7z -m0=lzma -mx=9 -mfb=64 -md=32m -ms=on -mhe=on"
### no Change after here
if [ ! -d "$DIR" ]; then echo "You MUST change DIR variable. TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup";  exit 0; fi
if [ ! -x "$TAR_PATH" ]; then echo "You MUST change TAR_PATH variable. Or install TAR. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
if [ ! -x "$p7zip_PATH" ]; then echo "You MUST change p7zip_PATH variable. Or install p7zip. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
if [ ! -x "$SendEmail_PATH" ]; then echo "You MUST change SendEmail_PATH variable. Or install SendEmail. Visit: http://wiki.znc.in/index.php?title=ZNC_Backup"; exit 0; fi
$TAR_PATH -cvf $DATEI1 $DIR
$p7zip_PATH $sevenzp $DATEI2 $DATEI1
echo ZNC Backup from $DATUM | $SendEmail_PATH -r $USER@$YOUREHOST -s ZNC-Backup-$DATUM -a $DATEI2 $MAILADRESSE1
rm -f $DATEI1 $DATEI2
  • Make script executable
chmod 755 /var/hda/web-apps/znc/html/znc-backup.sh
  • To run manually, execute the script from the /var/hda/web-apps/znc/html directory
./znc-backup.sh
  • Install a cron job as your First Admin User, not root and insert the following text:
crontab -e
40 0  * * 5 /var/hda/web-apps/znc/html/znc-backup.sh >/dev/null 2>&1

NOTE: This will run on Fri at 00:40 AM, but you can change to meet your needs.

Troubleshooting

Can't connect to server (No route to host)

If ZNC can't connect to a IRC server with the message:

Attempting to connect to [chat.freenode.net +7000] ...
Disconnected from IRC (No route to host).  Reconnecting...

You could try using the IP address of the server you are trying to connect to. For chat.freenode.net this IP is: 140.211.166.3

  • Go to your ZNC webadmin page
  • Login using your username and password
  • Click on "Your Settings"
  • Edit the server name in the Servers: text box.

ZNC will pickup this new server name the next time trying to connect (wait a minute or so).

Install Fails

If you have installed ZNC multiple times without success, perform the following as root user:

yum -y erase znc*
  • Once the RPMs have been removed, perform install.
  • Check /var/log/amahi-app-installer.log for details.