Jump to content
Not connected, Your IP: 18.227.114.125

cm0s

Members2
  • Content Count

    303
  • Joined

    ...
  • Last visited

    ...
  • Days Won

    10

Posts posted by cm0s


  1. run your network from terminal
    you are on kali anyway
    remove network-manager, eddie, set eth0 to down
    upon boot, edit resolve.conf, set your iptables to airvpn
    and push your dns 10.5.0.1, use ssl/stunnel config
    you might need to fix stunnel with this:
    
    # rm /usr/bin/stunnel
    # ln -s /usr/bin/stunnel4 /usr/bin/stunnel
    # cd /etc/stunnel
    # touch stunnel.conf
    # nano stunnel.conf
    cert=/path/to/pem
    key=/path/to/key
    ctrl+o, ctrl+x
    ################################
    have some tablez:
    iptables -F
    iptables -t nat -F
    iptables -t mangle -F
    iptables -X
    iptables -t nat -X
    iptables -t mangle -X
    iptables -P INPUT DROP
    iptables -P FORWARD DROP
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT # connectionz
    iptables -A INPUT -p tcp -m state --state NEW -m multiport --dports 80,443 -j ACCEPT # net, ssl
    iptables -A INPUT -i lo -j ACCEPT
    iptables -A OUTPUT -o lo -j ACCEPT #allow loopback access
    iptables -A OUTPUT -d 255.255.255.255 -j ACCEPT #communicate with any DHCP server/router
    iptables -A INPUT -s 255.255.255.255 -j ACCEPT #communicate with any DHCP server/router
    iptables -A INPUT -s 192.168.0.0/16 -d 192.168.0.0/16 -j ACCEPT #communicate within lan
    iptables -A OUTPUT -s 192.168.0.0/16 -d 192.168.0.0/16 -j ACCEPT
    iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
    iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT # make sure eth0/tun0 can communicate
    iptables -t nat -A PREROUTING -s 0/0 -p udp --dport 53 -j DNAT --to 10.5.0.1 #use vpn dns
    iptables -t nat -A PREROUTING -s 0/0 -p tcp --dport 53 -j DNAT --to 10.5.0.1 # use vpn dns
    iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE # map tun0 outgoing IP addy
    iptables -A OUTPUT -o eth0 ! -d 127.0.0.1 -p tcp --dport 1413 -j DROP # if traffic isn't vpn
    #######################
    
    # ifup eth0
    # stunnel "awesomeairvpnserver.ssl" --auth-nocache
    # openvpn --config "awesomeairvpnserver.ovpn" --auth-nocache
    # ping -c 1 duckduckgo.com
    
    i set my iface like this adjust for your needs:
    
    # The loopback network interface
    auto lo
    iface lo inet loopback
    
    # the static shit for eth0
    auto eth0
    iface eth0 inet static
    address 192.168.1.xxx
    gateway 192.168.1.1
    dns-nameservers 10.5.0.1
    
    in the router i shut off dhcp on my side leave it on for my isp on their side
    keeps me off the business account rates yet i still get the benefits of static on my
    local, had the same damn external ip on 'dhcp' from them for years anyway
    run my website on standalone box no problems, so anyone tells ya diff, i dunno works for
    me anyway, plus do your mac filter shit if needed, hide yer essid if wifi if this is a wifi config
    lemme know i'll post notes up on that that i got, how to connect with hidden essid or not hidden
    assign your hostname if needed in the router
    
    don't forget you can 'nohup' 
    say you boot debian old school right and want to see how much you can do just from the 
    prompt
    
    you can cd, ls, cd .., cp, cp -r, everything from there also and hit the net and have openvpn/stunnel goin
    from same window tho you need to use the command 'nohup' and put a '&' at the end
    
    i figured this out coz yeah, locked myself out of my vps many times 
    
    so say yer wanting to get stuff goin
    you up your eth0/enp2s2 
    then when you get to the stunnel part:
    # nohup stunnel "airvpnserver.ssl" --auth-nocache &
    then do your openvpn command
    
    now you won't see stuff 'finish' but you'll know yer connected do a nslookup and traceroute curl etc
    
    hope this helps i don't always explain stuff best way
    

     


  2. read a bit on the article and like his blog layout btw

     

    i'd suggest get a cheap cell phone or cheap lan line

    in case you have an emergency

     

    i'm actually in the same boat right now in a way

    i'm tired of the 'surveillance' type stuff done on cell

    phones today and will most likely get a cheap lan line

    phone for my home

     

    that way things are simpler for me

    my home then has a stable call in/out

     

    i have some 'backup' in case the net goes down

    which often it does in our area due to weather

     

    i do understand the financial side of things

     

    hopefully you get your config set up the way you want

     

    splif


  3. here's my idea:

    if you are an admin of say a torrent site do not get involved in other activiities that will bring attention to your community.

     

    stop with the bloat code on your websites, adware, scamware etc.

     

    put a link up for your community to be able to 'donate' what they can when they can

     

    might be better to mirror the site to the tor network for the magnets not have that available via clear

    so in a way you are running two sites same thing but the tor network has the magnets

     

    maybe put another site up separate from that onion address for the 'forum' community where you probably will need java running for all the admin junk, this way your 'java' site is tor only and separate from your magnet site

     

    hire an attorney if and when you can, if needed so you got some help if something goes wrong as it tends to

     

    if you have enough from donations give some of that back some how, whatever your ethics are, do some kind of good with it

     

    if your site grows beyond your ability, bring someone else in that can handle it and can keep your community safe

     

    drink tons of coffee, like way more than needed 

     

     

     

    # airvpn irc hidden service stealth mode ssl
    
    # mkdir hidircz
    # cd d0wnz
    # touch cool.motd
    # vim cool.motd
    hit 'i' copy paste
    text below or your own
    custom motd
    hit 'esc' key then type ':wq'
    ____ _ ____ _  _ ___  _  _ 
    |__| | |__/ |  | |__] |\ | 
    |  | | |  \  \/  |    | \| 
    ===========================                           
    https://airvpn.org
    
    add this to your torrc file
    mod for your own config if needed...
    
    VirtualAddrNetwork 10.192.0.0/10
    TransPort 9040
    DNSPort 53
    AutomapHostsOnResolve 1
    
    ##hidden service 
    HiddenServiceDir /var/lib/tor/
    HiddenServicePort 6697 127.0.0.1:6697
    HiddenServiceAuthorizeClient stealth IRCvisitor
    HidServAuth newtorsitenamehere.onion stealthpasshere
    
    you'll start tor and then stop tor to get your hidden service
    hostname and authorization cookie, this 'cookie' is in the hostname
    /var/lib/tor
    looks like this:
    newtorsitenamehere.onion yourauthcookieherebruh # client: IRCvisitor
    
    now remember in the torrc file below the port you created the 'IRCvisitor'
    without this information from /var/lib/tor added to the torrc file in the example
    above you cannot access the irc server or if it were http you can not access it
    even from the box hosting the irc/http server
    the advantage to stealth mode is this: it is NOT listed in the tor directory
    and if anything goes wrong with your irc server or you just want to create another openssl req -x509 -sha256 -newkey rsa:2048 -keyout ~/d0wnz/ircpriv.pem -out ~/d0wnz/ircert.pem -days 1024 -nodes -subj '/CN=irc.z4ojdtiaqvdfi4ys.onion' 
    'domain' no problem, you are not tied to anything, and anyone accessing your site/chat
    has to have contacted you to get the authorization cookie
    
    from hidircz directory...
    # openssl req -x509 -sha256 -newkey rsa:2048 -keyout /root/hidrircz/ircpriv.pem -out /root/hidircz/ircert.pem -days 1024 -nodes -subj '/CN=irc.newtorsitenamehere.onion' 
    # cat /root/hidircz/ircpriv.pem > hidz.pem
    # cat /root/hidircz/ircert.pem >> hidz.pem
    
    here's the python script....
    #################################
    
    #! /usr/bin/env python
    # https://github.com/jrosdahl/miniircd
    # Joel Rosdahl <joel@rosdahl.net>
    # pacman -S python-pyopenssl if needed
    
    import logging
    import os
    import re
    import select
    import socket
    import string
    import sys
    import tempfile
    import time
    from datetime import datetime
    from logging.handlers import RotatingFileHandler
    from optparse import OptionParser
    
    VERSION = "1.2.1"
    
    
    PY3 = sys.version_info[0] >= 3
    
    if PY3:
        def buffer_to_socket(msg):
            return msg.encode()
    
        def socket_to_buffer(buf):
            return buf.decode()
    else:
        def buffer_to_socket(msg):
            return msg
    
        def socket_to_buffer(buf):
            return buf
    
    
    def create_directory(path):
        if not os.path.isdir(path):
            os.makedirs(path)
    
    
    class Channel(object):
        def __init__(self, server, name):
            self.server = server
            self.name = name
            self.members = set()
            self._topic = ""
            self._key = None
            if self.server.state_dir:
                self._state_path = "%s/%s" % (
                    self.server.state_dir,
                    name.replace("_", "__").replace("/", "_"))
                self._read_state()
            else:
                self._state_path = None
    
        def add_member(self, client):
            self.members.add(client)
    
        def get_topic(self):
            return self._topic
    
        def set_topic(self, value):
            self._topic = value
            self._write_state()
    
        topic = property(get_topic, set_topic)
    
        def get_key(self):
            return self._key
    
        def set_key(self, value):
            self._key = value
            self._write_state()
    
        key = property(get_key, set_key)
    
        def remove_client(self, client):
            self.members.discard(client)
            if not self.members:
                self.server.remove_channel(self)
    
        def _read_state(self):
            if not (self._state_path and os.path.exists(self._state_path)):
                return
            data = {}
    
            with open(self._state_path, "rb") as state_file:
                exec(state_file.read(), {}, data)
    
            self._topic = data.get("topic", "")
            self._key = data.get("key")
    
        def _write_state(self):
            if not self._state_path:
                return
            (fd, path) = tempfile.mkstemp(dir=os.path.dirname(self._state_path))
            fp = os.fdopen(fd, "w")
            fp.write("topic = %r\n" % self.topic)
            fp.write("key = %r\n" % self.key)
            fp.close()
            os.rename(path, self._state_path)
    
    
    class Client(object):
        __linesep_regexp = re.compile(r"\r?\n")
        # The RFC limit for nicknames is 9 characters, but what the heck.
        __valid_nickname_regexp = re.compile(
            r"^[][\`_^{|}A-Za-z][][\`_^{|}A-Za-z0-9-]{0,50}$")
        __valid_channelname_regexp = re.compile(
            r"^[+!][^\x00\x07\x0a\x0d ,:]{0,50}$")
    
        def __init__(self, server, socket):
            self.server = server
            self.socket = socket
            self.channels = {}  # irc_lower(Channel name) --> Channel
            self.nickname = None
            self.user = None
            self.realname = None
            (self.host, self.port) = socket.getpeername()
            self.__timestamp = time.time()
            self.__readbuffer = ""
            self.__writebuffer = ""
            self.__sent_ping = False
            if self.server.password:
                self.__handle_command = self.__pass_handler
            else:
                self.__handle_command = self.__registration_handler
    
        def get_prefix(self):
            return "%s!%s@%s" % (self.nickname, self.user, self.host)
        prefix = property(get_prefix)
    
        def check_aliveness(self):
            now = time.time()
            if self.__timestamp + 180 < now:
                self.disconnect("ping timeout")
                return
            if not self.__sent_ping and self.__timestamp + 90 < now:
                if self.__handle_command == self.__command_handler:
                    # Registered.
                    self.message("PING :%s" % self.server.name)
                    self.__sent_ping = True
                else:
                    # Not registered.
                    self.disconnect("ping timeout")
    
        def write_queue_size(self):
            return len(self.__writebuffer)
    
        def __parse_read_buffer(self):
            lines = self.__linesep_regexp.split(self.__readbuffer)
            self.__readbuffer = lines[-1]
            lines = lines[:-1]
            for line in lines:
                if not line:
                    # Empty line. Ignore.
                    continue
                x = line.split(" ", 1)
                command = x[0].upper()
                if len(x) == 1:
                    arguments = []
                else:
                    if len(x[1]) > 0 and x[1][0] == ":":
                        arguments = [x[1][1:]]
                    else:
                        y = x[1].split(" :", 1)
                        arguments = y[0].split()
                        if len(y) == 2:
                            arguments.append(y[1])
                self.__handle_command(command, arguments)
    
        def __pass_handler(self, command, arguments):
            server = self.server
            if command == "PASS":
                if len(arguments) == 0:
                    self.reply_461("PASS")
                else:
                    if arguments[0].lower() == server.password:
                        self.__handle_command = self.__registration_handler
                    else:
                        self.reply("464 :Password incorrect")
            elif command == "QUIT":
                self.disconnect("Client quit")
                return
    
        def __registration_handler(self, command, arguments):
            server = self.server
            if command == "NICK":
                if len(arguments) < 1:
                    self.reply("431 :No nickname given")
                    return
                nick = arguments[0]
                if server.get_client(nick):
                    self.reply("433 * %s :Nickname is already in use" % nick)
                elif not self.__valid_nickname_regexp.match(nick):
                    self.reply("432 * %s :Erroneous nickname" % nick)
                else:
                    self.nickname = nick
                    server.client_changed_nickname(self, None)
            elif command == "USER":
                if len(arguments) < 4:
                    self.reply_461("USER")
                    return
                self.user = arguments[0]
                self.realname = arguments[3]
            elif command == "QUIT":
                self.disconnect("Client quit")
                return
            if self.nickname and self.user:
                self.reply("001 %s :Hi, welcome to IRC" % self.nickname)
                self.reply("002 %s :Your host is %s, running version miniircd-%s"
                           % (self.nickname, server.name, VERSION))
                self.reply("003 %s :This server was created sometime"
                           % self.nickname)
                self.reply("004 %s %s miniircd-%s o o"
                           % (self.nickname, server.name, VERSION))
                self.send_lusers()
                self.send_motd()
                self.__handle_command = self.__command_handler
    
        def __send_names(self, arguments, for_join=False):
            server = self.server
            valid_channel_re = self.__valid_channelname_regexp
            if len(arguments) > 0:
                channelnames = arguments[0].split(",")
            else:
                channelnames = sorted(self.channels.keys())
            if len(arguments) > 1:
                keys = arguments[1].split(",")
            else:
                keys = []
            keys.extend((len(channelnames) - len(keys)) * [None])
            for (i, channelname) in enumerate(channelnames):
                if for_join and irc_lower(channelname) in self.channels:
                    continue
                if not valid_channel_re.match(channelname):
                    self.reply_403(channelname)
                    continue
                channel = server.get_channel(channelname)
                if channel.key is not None and channel.key != keys[i]:
                    self.reply(
                        "475 %s %s :Cannot join channel (+k) - bad key"
                        % (self.nickname, channelname))
                    continue
    
                if for_join:
                    channel.add_member(self)
                    self.channels[irc_lower(channelname)] = channel
                    self.message_channel(channel, "JOIN", channelname, True)
                    self.channel_log(channel, "joined", meta=True)
                    if channel.topic:
                        self.reply("332 %s %s :%s"
                                   % (self.nickname, channel.name, channel.topic))
                    else:
                        self.reply("331 %s %s :No topic is set"
                                   % (self.nickname, channel.name))
                names_prefix = "353 %s = %s :" % (self.nickname, channelname)
                names = ""
                # Max length: reply prefix ":server_name(space)" plus CRLF in
                # the end.
                names_max_len = 512 - (len(server.name) + 2 + 2)
                for name in sorted(x.nickname for x in channel.members):
                    if not names:
                        names = names_prefix + name
                    # Using >= to include the space between "names" and "name".
                    elif len(names) + len(name) >= names_max_len:
                        self.reply(names)
                        names = names_prefix + name
                    else:
                        names += " " + name
                if names:
                    self.reply(names)
                self.reply("366 %s %s :End of NAMES list"
                           % (self.nickname, channelname))
    
        def __command_handler(self, command, arguments):
            def away_handler():
                pass
    
            def ison_handler():
                if len(arguments) < 1:
                    self.reply_461("ISON")
                    return
                nicks = arguments
                online = [n for n in nicks if server.get_client(n)]
                self.reply("303 %s :%s" % (self.nickname, " ".join(online)))
    
            def join_handler():
                if len(arguments) < 1:
                    self.reply_461("JOIN")
                    return
                if arguments[0] == "0":
                    for (channelname, channel) in self.channels.items():
                        self.message_channel(channel, "PART", channelname, True)
                        self.channel_log(channel, "left", meta=True)
                        server.remove_member_from_channel(self, channelname)
                    self.channels = {}
                    return
                self.__send_names(arguments, for_join=True)
    
            def list_handler():
                if len(arguments) < 1:
                    channels = server.channels.values()
                else:
                    channels = []
                    for channelname in arguments[0].split(","):
                        if server.has_channel(channelname):
                            channels.append(server.get_channel(channelname))
    
                sorted_channels = sorted(channels, key=lambda x: x.name)
                for channel in sorted_channels:
                    self.reply("322 %s %s %d :%s"
                               % (self.nickname, channel.name,
                                  len(channel.members), channel.topic))
                self.reply("323 %s :End of LIST" % self.nickname)
    
            def lusers_handler():
                self.send_lusers()
    
            def mode_handler():
                if len(arguments) < 1:
                    self.reply_461("MODE")
                    return
                targetname = arguments[0]
                if server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    if len(arguments) < 2:
                        if channel.key:
                            modes = "+k"
                            if irc_lower(channel.name) in self.channels:
                                modes += " %s" % channel.key
                        else:
                            modes = "+"
                        self.reply("324 %s %s %s"
                                   % (self.nickname, targetname, modes))
                        return
                    flag = arguments[1]
                    if flag == "+k":
                        if len(arguments) < 3:
                            self.reply_461("MODE")
                            return
                        key = arguments[2]
                        if irc_lower(channel.name) in self.channels:
                            channel.key = key
                            self.message_channel(
                                channel, "MODE", "%s +k %s" % (channel.name, key),
                                True)
                            self.channel_log(
                                channel, "set channel key to %s" % key, meta=True)
                        else:
                            self.reply("442 %s :You're not on that channel"
                                       % targetname)
                    elif flag == "-k":
                        if irc_lower(channel.name) in self.channels:
                            channel.key = None
                            self.message_channel(
                                channel, "MODE", "%s -k" % channel.name,
                                True)
                            self.channel_log(
                                channel, "removed channel key", meta=True)
                        else:
                            self.reply("442 %s :You're not on that channel"
                                       % targetname)
                    else:
                        self.reply("472 %s %s :Unknown MODE flag"
                                   % (self.nickname, flag))
                elif targetname == self.nickname:
                    if len(arguments) == 1:
                        self.reply("221 %s +" % self.nickname)
                    else:
                        self.reply("501 %s :Unknown MODE flag" % self.nickname)
                else:
                    self.reply_403(targetname)
    
            def motd_handler():
                self.send_motd()
    
            def names_handler():
                self.__send_names(arguments)
    
            def nick_handler():
                if len(arguments) < 1:
                    self.reply("431 :No nickname given")
                    return
                newnick = arguments[0]
                client = server.get_client(newnick)
                if newnick == self.nickname:
                    pass
                elif client and client is not self:
                    self.reply("433 %s %s :Nickname is already in use"
                               % (self.nickname, newnick))
                elif not self.__valid_nickname_regexp.match(newnick):
                    self.reply("432 %s %s :Erroneous Nickname"
                               % (self.nickname, newnick))
                else:
                    for x in self.channels.values():
                        self.channel_log(
                            x, "changed nickname to %s" % newnick, meta=True)
                    oldnickname = self.nickname
                    self.nickname = newnick
                    server.client_changed_nickname(self, oldnickname)
                    self.message_related(
                        ":%s!%s@%s NICK %s"
                        % (oldnickname, self.user, self.host, self.nickname),
                        True)
    
            def notice_and_privmsg_handler():
                if len(arguments) == 0:
                    self.reply("411 %s :No recipient given (%s)"
                               % (self.nickname, command))
                    return
                if len(arguments) == 1:
                    self.reply("412 %s :No text to send" % self.nickname)
                    return
                targetname = arguments[0]
                message = arguments[1]
                client = server.get_client(targetname)
                if client:
                    client.message(":%s %s %s :%s"
                                   % (self.prefix, command, targetname, message))
                elif server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    self.message_channel(
                        channel, command, "%s :%s" % (channel.name, message))
                    self.channel_log(channel, message)
                else:
                    self.reply("401 %s %s :No such nick/channel"
                               % (self.nickname, targetname))
    
            def part_handler():
                if len(arguments) < 1:
                    self.reply_461("PART")
                    return
                if len(arguments) > 1:
                    partmsg = arguments[1]
                else:
                    partmsg = self.nickname
                for channelname in arguments[0].split(","):
                    if not valid_channel_re.match(channelname):
                        self.reply_403(channelname)
                    elif not irc_lower(channelname) in self.channels:
                        self.reply("442 %s %s :You're not on that channel"
                                   % (self.nickname, channelname))
                    else:
                        channel = self.channels[irc_lower(channelname)]
                        self.message_channel(
                            channel, "PART", "%s :%s" % (channelname, partmsg),
                            True)
                        self.channel_log(channel, "left (%s)" % partmsg, meta=True)
                        del self.channels[irc_lower(channelname)]
                        server.remove_member_from_channel(self, channelname)
    
            def ping_handler():
                if len(arguments) < 1:
                    self.reply("409 %s :No origin specified" % self.nickname)
                    return
                self.reply("PONG %s :%s" % (server.name, arguments[0]))
    
            def pong_handler():
                pass
    
            def quit_handler():
                if len(arguments) < 1:
                    quitmsg = self.nickname
                else:
                    quitmsg = arguments[0]
                self.disconnect(quitmsg)
    
            def topic_handler():
                if len(arguments) < 1:
                    self.reply_461("TOPIC")
                    return
                channelname = arguments[0]
                channel = self.channels.get(irc_lower(channelname))
                if channel:
                    if len(arguments) > 1:
                        newtopic = arguments[1]
                        channel.topic = newtopic
                        self.message_channel(
                            channel, "TOPIC", "%s :%s" % (channelname, newtopic),
                            True)
                        self.channel_log(
                            channel, "set topic to %r" % newtopic, meta=True)
                    else:
                        if channel.topic:
                            self.reply("332 %s %s :%s"
                                       % (self.nickname, channel.name,
                                          channel.topic))
                        else:
                            self.reply("331 %s %s :No topic is set"
                                       % (self.nickname, channel.name))
                else:
                    self.reply("442 %s :You're not on that channel" % channelname)
    
            def wallops_handler():
                if len(arguments) < 1:
                    self.reply_461("WALLOPS")
                    return
                message = arguments[0]
                for client in server.clients.values():
                    client.message(":%s NOTICE %s :Global notice: %s"
                                   % (self.prefix, client.nickname, message))
    
            def who_handler():
                if len(arguments) < 1:
                    return
                targetname = arguments[0]
                if server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    for member in channel.members:
                        self.reply("352 %s %s %s %s %s %s H :0 %s"
                                   % (self.nickname, targetname, member.user,
                                      member.host, server.name, member.nickname,
                                      member.realname))
                    self.reply("315 %s %s :End of WHO list"
                               % (self.nickname, targetname))
    
            def whois_handler():
                if len(arguments) < 1:
                    return
                username = arguments[0]
                user = server.get_client(username)
                if user:
                    self.reply("311 %s %s %s %s * :%s"
                               % (self.nickname, user.nickname, user.user,
                                  user.host, user.realname))
                    self.reply("312 %s %s %s :%s"
                               % (self.nickname, user.nickname, server.name,
                                  server.name))
                    self.reply("319 %s %s :%s"
                               % (self.nickname, user.nickname,
                                  " ".join(user.channels)))
                    self.reply("318 %s %s :End of WHOIS list"
                               % (self.nickname, user.nickname))
                else:
                    self.reply("401 %s %s :No such nick"
                               % (self.nickname, username))
    
            handler_table = {
                "AWAY": away_handler,
                "ISON": ison_handler,
                "JOIN": join_handler,
                "LIST": list_handler,
                "LUSERS": lusers_handler,
                "MODE": mode_handler,
                "MOTD": motd_handler,
                "NAMES": names_handler,
                "NICK": nick_handler,
                "NOTICE": notice_and_privmsg_handler,
                "PART": part_handler,
                "PING": ping_handler,
                "PONG": pong_handler,
                "PRIVMSG": notice_and_privmsg_handler,
                "QUIT": quit_handler,
                "TOPIC": topic_handler,
                "WALLOPS": wallops_handler,
                "WHO": who_handler,
                "WHOIS": whois_handler,
            }
            server = self.server
            valid_channel_re = self.__valid_channelname_regexp
            try:
                handler_table[command]()
            except KeyError:
                self.reply("421 %s %s :Unknown command" % (self.nickname, command))
    
        def socket_readable_notification(self):
            try:
                data = self.socket.recv(2 ** 10)
                self.server.print_debug(
                    "[%s:%d] -> %r" % (self.host, self.port, data))
                quitmsg = "EOT"
            except socket.error as x:
                data = ""
                quitmsg = x
            if data:
                self.__readbuffer += socket_to_buffer(data)
                self.__parse_read_buffer()
                self.__timestamp = time.time()
                self.__sent_ping = False
            else:
                self.disconnect(quitmsg)
    
        def socket_writable_notification(self):
            try:
                sent = self.socket.send(buffer_to_socket(self.__writebuffer))
                self.server.print_debug(
                    "[%s:%d] <- %r" % (
                        self.host, self.port, self.__writebuffer[:sent]))
                self.__writebuffer = self.__writebuffer[sent:]
            except socket.error as x:
                self.disconnect(x)
    
        def disconnect(self, quitmsg):
            self.message("ERROR :%s" % quitmsg)
            self.server.print_info(
                "Disconnected connection from %s:%s (%s)." % (
                    self.host, self.port, quitmsg))
            self.socket.close()
            self.server.remove_client(self, quitmsg)
    
        def message(self, msg):
            self.__writebuffer += msg + "\r\n"
    
        def reply(self, msg):
            self.message(":%s %s" % (self.server.name, msg))
    
        def reply_403(self, channel):
            self.reply("403 %s %s :No such channel" % (self.nickname, channel))
    
        def reply_461(self, command):
            nickname = self.nickname or "*"
            self.reply("461 %s %s :Not enough parameters" % (nickname, command))
    
        def message_channel(self, channel, command, message, include_self=False):
            line = ":%s %s %s" % (self.prefix, command, message)
            for client in channel.members:
                if client != self or include_self:
                    client.message(line)
    
        def channel_log(self, channel, message, meta=False):
            if not self.server.channel_log_dir:
                return
            if meta:
                format = "[%s] * %s %s\n"
            else:
                format = "[%s] <%s> %s\n"
            timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
            logname = channel.name.replace("_", "__").replace("/", "_")
            fp = open("%s/%s.log" % (self.server.channel_log_dir, logname), "a")
            fp.write(format % (timestamp, self.nickname, message))
            fp.close()
    
        def message_related(self, msg, include_self=False):
            clients = set()
            if include_self:
                clients.add(self)
            for channel in self.channels.values():
                clients |= channel.members
            if not include_self:
                clients.discard(self)
            for client in clients:
                client.message(msg)
    
        def send_lusers(self):
            self.reply("251 %s :There are %d users and 0 services on 1 server"
                       % (self.nickname, len(self.server.clients)))
    
        def send_motd(self):
            server = self.server
            motdlines = server.get_motd_lines()
            if motdlines:
                self.reply("375 %s :- %s Message of the day -"
                           % (self.nickname, server.name))
                for line in motdlines:
                    self.reply("372 %s :- %s" % (self.nickname, line.rstrip()))
                self.reply("376 %s :End of /MOTD command" % self.nickname)
            else:
                self.reply("422 %s :MOTD File is missing" % self.nickname)
    
    
    class Server(object):
        def __init__(self, options):
            self.ports = options.ports
            self.password = options.password
            self.ssl_pem_file = options.ssl_pem_file
            self.motdfile = options.motd
            self.verbose = options.verbose
            self.debug = options.debug
            self.channel_log_dir = options.channel_log_dir
            self.chroot = options.chroot
            self.setuid = options.setuid
            self.state_dir = options.state_dir
            self.log_file = options.log_file
            self.log_max_bytes = options.log_max_size * 1024 * 1024
            self.log_count = options.log_count
            self.logger = None
    
            if options.password_file:
                with open(options.password_file, "r") as fp:
                    self.password = fp.read().strip("\n")
    
            if self.ssl_pem_file:
                self.ssl = __import__("ssl")
    
            # Find certificate after daemonization if path is relative:
            if self.ssl_pem_file and os.path.exists(self.ssl_pem_file):
                self.ssl_pem_file = os.path.abspath(self.ssl_pem_file)
            # else: might exist in the chroot jail, so just continue
    
            if options.listen:
                self.address = socket.gethostbyname(options.listen)
            else:
                self.address = ""
            server_name_limit = 63  # From the RFC.
            self.name = socket.getfqdn(self.address)[:server_name_limit]
    
            self.channels = {}  # irc_lower(Channel name) --> Channel instance.
            self.clients = {}  # Socket --> Client instance.
            self.nicknames = {}  # irc_lower(Nickname) --> Client instance.
            if self.channel_log_dir:
                create_directory(self.channel_log_dir)
            if self.state_dir:
                create_directory(self.state_dir)
    
        def make_pid_file(self, filename):
            try:
                fd = os.open(filename, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644)
                os.write(fd, "%i\n" % os.getpid())
                os.close(fd)
            except:
                self.print_error("Could not create PID file %r" % filename)
                sys.exit(1)
    
        def daemonize(self):
            try:
                pid = os.fork()
                if pid > 0:
                    sys.exit(0)
            except OSError:
                sys.exit(1)
            os.setsid()
            try:
                pid = os.fork()
                if pid > 0:
                    self.print_info("PID: %d" % pid)
                    sys.exit(0)
            except OSError:
                sys.exit(1)
            os.chdir("/")
            os.umask(0)
            dev_null = open("/dev/null", "r+")
            os.dup2(dev_null.fileno(), sys.stdout.fileno())
            os.dup2(dev_null.fileno(), sys.stderr.fileno())
            os.dup2(dev_null.fileno(), sys.stdin.fileno())
    
        def get_client(self, nickname):
            return self.nicknames.get(irc_lower(nickname))
    
        def has_channel(self, name):
            return irc_lower(name) in self.channels
    
        def get_channel(self, channelname):
            if irc_lower(channelname) in self.channels:
                channel = self.channels[irc_lower(channelname)]
            else:
                channel = Channel(self, channelname)
                self.channels[irc_lower(channelname)] = channel
            return channel
    
        def get_motd_lines(self):
            if self.motdfile:
                try:
                    return open(self.motdfile).readlines()
                except IOError:
                    return ["Could not read MOTD file %r." % self.motdfile]
            else:
                return []
    
        def print_info(self, msg):
            if self.verbose:
                print(msg)
                sys.stdout.flush()
            if self.logger:
                self.logger.info(msg)
    
        def print_debug(self, msg):
            if self.debug:
                print(msg)
                sys.stdout.flush()
            if self.logger:
                self.logger.debug(msg)
    
        def print_error(self, msg):
            sys.stderr.write("%s\n" % msg)
            if self.logger:
                self.logger.error(msg)
    
        def client_changed_nickname(self, client, oldnickname):
            if oldnickname:
                del self.nicknames[irc_lower(oldnickname)]
            self.nicknames[irc_lower(client.nickname)] = client
    
        def remove_member_from_channel(self, client, channelname):
            if irc_lower(channelname) in self.channels:
                channel = self.channels[irc_lower(channelname)]
                channel.remove_client(client)
    
        def remove_client(self, client, quitmsg):
            client.message_related(":%s QUIT :%s" % (client.prefix, quitmsg))
            for x in client.channels.values():
                client.channel_log(x, "quit (%s)" % quitmsg, meta=True)
                x.remove_client(client)
            if client.nickname \
                    and irc_lower(client.nickname) in self.nicknames:
                del self.nicknames[irc_lower(client.nickname)]
            del self.clients[client.socket]
    
        def remove_channel(self, channel):
            del self.channels[irc_lower(channel.name)]
    
        def start(self):
            serversockets = []
            for port in self.ports:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                try:
                    s.bind((self.address, port))
                except socket.error as e:
                    self.print_error("Could not bind port %s: %s." % (port, e))
                    sys.exit(1)
                s.listen(5)
                serversockets.append(s)
                del s
                self.print_info("Listening on port %d." % port)
            if self.chroot:
                os.chdir(self.chroot)
                os.chroot(self.chroot)
                self.print_info("Changed root directory to %s" % self.chroot)
            if self.setuid:
                os.setgid(self.setuid[1])
                os.setuid(self.setuid[0])
                self.print_info("Setting uid:gid to %s:%s"
                                % (self.setuid[0], self.setuid[1]))
    
            self.init_logging()
            try:
                self.run(serversockets)
            except:
                if self.logger:
                    self.logger.exception("Fatal exception")
                raise
    
        def init_logging(self):
            if not self.log_file:
                return
    
            log_level = logging.INFO
            if self.debug:
                log_level = logging.DEBUG
            self.logger = logging.getLogger("miniircd")
            formatter = logging.Formatter(
                ("%(asctime)s - %(name)s[%(process)d] - "
                 "%(levelname)s - %(message)s"))
            fh = RotatingFileHandler(
                self.log_file,
                maxBytes=self.log_max_bytes,
                backupCount=self.log_count)
            fh.setLevel(log_level)
            fh.setFormatter(formatter)
            self.logger.setLevel(log_level)
            self.logger.addHandler(fh)
    
        def run(self, serversockets):
            last_aliveness_check = time.time()
            while True:
                (iwtd, owtd, ewtd) = select.select(
                    serversockets + [x.socket for x in self.clients.values()],
                    [x.socket for x in self.clients.values()
                     if x.write_queue_size() > 0],
                    [],
                    10)
                for x in iwtd:
                    if x in self.clients:
                        self.clients[x].socket_readable_notification()
                    else:
                        (conn, addr) = x.accept()
                        if self.ssl_pem_file:
                            try:
                                conn = self.ssl.wrap_socket(
                                    conn,
                                    server_side=True,
                                    certfile=self.ssl_pem_file,
                                    keyfile=self.ssl_pem_file)
                            except Exception as e:
                                self.print_error(
                                    "SSL error for connection from %s:%s: %s" % (
                                        addr[0], addr[1], e))
                                continue
                        try:
                            self.clients[conn] = Client(self, conn)
                            self.print_info("Accepted connection from %s:%s." % (
                                addr[0], addr[1]))
                        except socket.error as e:
                            try:
                                conn.close()
                            except:
                                pass
                for x in owtd:
                    if x in self.clients:  # client may have been disconnected
                        self.clients[x].socket_writable_notification()
                now = time.time()
                if last_aliveness_check + 10 < now:
                    for client in list(self.clients.values()):
                        client.check_aliveness()
                    last_aliveness_check = now
    
    
    _maketrans = str.maketrans if PY3 else string.maketrans
    _ircstring_translation = _maketrans(
        string.ascii_lowercase.upper() + "[]\\^",
        string.ascii_lowercase + "{}|~")
    
    
    def irc_lower(s):
        return s.translate(_ircstring_translation)
    
    
    def main(argv):
        op = OptionParser(
            version=VERSION,
            description="miniircd is a small and limited IRC server.")
        op.add_option(
            "--channel-log-dir",
            metavar="X",
            help="store channel log in directory X")
        op.add_option(
            "-d", "--daemon",
            action="store_true",
            help="fork and become a daemon")
        op.add_option(
            "--debug",
            action="store_true",
            help="print debug messages to stdout")
        op.add_option(
            "--listen",
            metavar="X",
            help="listen on specific IP address X")
        op.add_option(
            "--log-count",
            metavar="X", default=10, type="int",
            help="keep X log files; default: %default")
        op.add_option(
            "--log-file",
            metavar="X",
            help="store log in file X")
        op.add_option(
            "--log-max-size",
            metavar="X", default=10, type="int",
            help="set maximum log file size to X MiB; default: %default MiB")
        op.add_option(
            "--motd",
            metavar="X",
            help="display file X as message of the day")
        op.add_option(
            "--pid-file",
            metavar="X",
            help="write PID to file X")
        op.add_option(
            "-p", "--password",
            metavar="X",
            help="require connection password X; default: no password")
        op.add_option(
            "--password-file",
            metavar="X",
            help=("require connection password stored in file X;"
                  " default: no password"))
        op.add_option(
            "--ports",
            metavar="X",
            help="listen to ports X (a list separated by comma or whitespace);"
                 " default: 6667 or 6697 if SSL is enabled")
        op.add_option(
            "-s", "--ssl-pem-file",
            metavar="FILE",
            help="enable SSL and use FILE as the .pem certificate+key")
        op.add_option(
            "--state-dir",
            metavar="X",
            help="save persistent channel state (topic, key) in directory X")
        op.add_option(
            "--verbose",
            action="store_true",
            help="be verbose (print some progress messages to stdout)")
        if os.name == "posix":
            op.add_option(
                "--chroot",
                metavar="X",
                help="change filesystem root to directory X after startup"
                     " (requires root)")
            op.add_option(
                "--setuid",
                metavar="U[:G]",
                help="change process user (and optionally group) after startup"
                     " (requires root)")
        else:
            op.chroot = False
            op.setuid = False
    
        (options, args) = op.parse_args(argv[1:])
        if options.debug:
            options.verbose = True
        if options.ports is None:
            if options.ssl_pem_file is None:
                options.ports = "6667"
            else:
                options.ports = "6697"
        if options.chroot:
            if os.getuid() != 0:
                op.error("Must be root to use --chroot")
        if options.setuid:
            from pwd import getpwnam
            from grp import getgrnam
            if os.getuid() != 0:
                op.error("Must be root to use --setuid")
            matches = options.setuid.split(":")
            if len(matches) == 2:
                options.setuid = (getpwnam(matches[0]).pw_uid,
                                  getgrnam(matches[1]).gr_gid)
            elif len(matches) == 1:
                options.setuid = (getpwnam(matches[0]).pw_uid,
                                  getpwnam(matches[0]).pw_gid)
            else:
                op.error("Specify a user, or user and group separated by a colon,"
                         " e.g. --setuid daemon, --setuid nobody:nobody")
        if (os.getuid() == 0 or os.getgid() == 0) and not options.setuid:
            op.error("Running this service as root is not recommended. Use the"
                     " --setuid option to switch to an unprivileged account after"
                     " startup. If you really intend to run as root, use"
                     " \"--setuid root\".")
    
        ports = []
        for port in re.split(r"[,\s]+", options.ports):
            try:
                ports.append(int(port))
            except ValueError:
                op.error("bad port: %r" % port)
        options.ports = ports
        server = Server(options)
        if options.daemon:
            server.daemonize()
        if options.pid_file:
            server.make_pid_file(options.pid_file)
        try:
            server.start()
        except KeyboardInterrupt:
            server.print_error("Interrupted.")
    
    
    main(sys.argv)
    
    #################################
    
    top of the script don't think needed just in case
    ya might add 'import ssl'
    on github the python file is named a bit different
    to start the script save it as example: minircd.py
    chmod +x the script
    
    as root from hidircz directory with your pem file and motd file:
    # python minircd.py --ssl-pem-file=/root/hidircz/hidz.pem --listen 127.0.0.1 --motd=huh.motd --setuid=root
    
    i didn't test this out but to run the script as non root ya might need change directory to say /home/nonrootuser
    move everything there, chown -R nonroot:nonroot all the files
    so ssl doesn't gripe about an error i might be wrong on this fyi 
    
    to get help with the irc server:
    # python minircd.py -h
    
    i forgot to mention to start tor at least on arch:
    # /usr/bin/tor -f /etc/tor/torrc
    
    so now you have a irc tor chat server up in stealth mode
    plus an additional layer of ssl 
    
    the clients say via irssi can connect as follows:
    # socat TCP4-LISTEN:8000,reuseaddr,fork SOCKS4a:127.0.0.1:newtorsitenamehere.onion:6697,socksport=9050
    
    you don't add the 'irc' in front of the 'domain' just the onion address without 'irc' 
    
    then launch irssi and to connect
    /connect -ssl 127.0.0.1 8000
    
    you can create a room join chat typical irc stuff
    anything done as /whois will show localhost no ip info
    
    for pidgin users little different but not much...
    basic tab is irc protocol
    yer user name
    server is the tor address without 'irc'
    advanced tab
    port 6697
    proxy tab...
    proxy is http
    host 127.0.0.1 port 8118
    
    start privoxy before connecting:
    # /usr/bin/privoxy --no-daemon /etc/privoxy/config
    
    here is my privoxy config:
    #######################################
    
    # Generally, this file goes in /etc/privoxy/config
    # unfucked config by cm0s 010117
    # to start /usr/bin/privoxy --no-dameon /etc/privoxy/config
    # Tor listens as a SOCKS4a proxy here:
    forward-socks5 / 127.0.0.1:9050 .
    
    # confz
    confdir /etc/privoxy
    logdir /var/log/privoxy
    # actionsfile standard  # Internal purpose, recommended
    actionsfile default.action   # Main actions file
    actionsfile user.action      # User customizations
    filterfile default.filter
    
    # timeout shit
    keep-alive-timeout 600
    # mohr timeout shit
    default-server-timeout 600
    # yet mohhhrrr...
    socket-timeout 600
    
    # Don't log interesting things, only startup messages, warnings and errors
    logfile logfile
    #jarfile jarfile
    #debug   0    # show each GET/POST/CONNECT request
    debug   4096 # Startup banner and warnings
    debug   8192 # Errors - *we highly recommended enabling this*
    
    user-manual /usr/share/doc/privoxy/user-manual
    listen-address  localhost:8118
    toggle  1
    enable-remote-toggle 0
    enable-edit-actions 0
    enable-remote-http-toggle 0
    buffer-limit 4096
    #
    #
    ########################################
    
    a quick side note:
    make sure logging is off in pidgin and also the otr plugin
    
    so recap, ya just launched your very own irc chat server
    can make your own motd, publish your otr key add whatever custom
    stuff ya want and ya really made it private coz it's in stealth mode
    stealth mode tor is NOT listed in the tor directory and even if someone
    finds your onion address they can't do anything, won't even let them 
    scan your address without the auth cookie, and you added another layer of ssl
    
    cheerz
    
    splif
    
    

  4. old information on hushmail but thought important:

     

    https://www.wired.com/2007/11/encrypted-e-mai/

     

    https://www.schneier.com/blog/archives/2007/11/hushmail_turns.html

     

    plus my 'review' and thoughts on hushmail:  https://splif.me/rantz.html

     

    i'm not hustling steroids or other illegal drugs through anyone let alone

     

    an email account of any kind anywhere.  now, if you have puppy treats

     

    let me know, i'll send ya an email using this:

     

    /
    / make sure gpg and gpa is installed...
    / what i like to do is for even a simple txt file is put it in 
    / a directory then archive it so say i got a txt file called 'email2bob' 
    / cd your desired location, this example say 'emailstuff'
    # mkdir ~/emailstuff
    # cd emailstuff
    # touch email2bob
    # nano email2bob
    / write email to bob
    # ctrl+o, ctrl+x, enter
    / now to backup out of the directory so we can encrypt the whole directory...
    # cd ..
    # tar -zcvf emailstuff.tar.gz emailstuff
    / now to generate a sha256 for that archive, this can be sent via separate email
    / to bob so he's got double security, email is going to be sha checked, encrypted
    / AND signed with my public key, if none of that matches, he knows it's been messed with 
    # sha256sum emailstuff.tar.gz
    / copy those numbers, it's a long line and email that to bob separately 
    / now at this point, we got the archive created, have sha256 created for it
    / we still need to sign it so they know it came from us only...
    # gpg --armor --detach-sign emailstuff.tar.gz
    / this signs the archive with your signature now to encrypt it...
    # gpg -o emailstuff.tar.gz.gpg --symmetric --cipher-algo aes256 emailstuff.tar.gz
    / this encrypts the archive, now you can email it, txt message or a
    / phone call then give them the pass for decryption 
    / bob gets the email with attachment saves it to his box now to decrypt it....
    # gpg -o emailstuff.tar.gz -d emailstuff.tar.gz.gpg
    / the archive is decrypted, at this point now to verify the that the file was signed by your public key 
    / bob can copy your public to his computer and copy the files asc file that was sent separately...
    / for bob to import your public key he runs:
    # gpg --import yourkey.asc
    / bob now wants to verify your signature
    # gpg --verify emailstuff.tar.gz.asc emailstuff.tar.gz
    / bob will see a 'warning not verified' but important part is 'good signature'
    / if all good now to verify the sha256....
    # sha256sum emailstuff.tar.gz
    / again if all good there numbers match bob knows the file he has is from you, was encrypted and not tampered with
    / now for bob to unwrap the archive...
    # tar -zxvf emailstuff.tar.gz
    / once bob has that unwrapped he can open the text file with whatever app he likes and read your email 

  5. 5951a9ac5fc86.png

     

     

     

    https://www.nytimes.com/2017/06/27/technology/eu-google-fine.html

     

     

     

     

    # airvpn irc hidden service stealth mode ssl

    # mkdir hidircz
    # cd d0wnz
    # touch cool.motd
    # vim cool.motd
    hit 'i' copy paste
    text below or your own
    custom motd
    hit 'esc' key then type ':wq'
    ____ _ ____ _  _ ___  _  _
    |__| | |__/ |  | |__] |\ |
    |  | | |  \  \/  |    | \|
    ===========================                          
    https://airvpn.org

    add this to your torrc file
    mod for your own config if needed...

    VirtualAddrNetwork 10.192.0.0/10
    TransPort 9040
    DNSPort 53
    AutomapHostsOnResolve 1

    ##hidden service
    HiddenServiceDir /var/lib/tor/
    HiddenServicePort 6697 127.0.0.1:6697
    HiddenServiceAuthorizeClient stealth IRCvisitor
    HidServAuth newtorsitenamehere.onion stealthpasshere

    you'll start tor and then stop tor to get your hidden service
    hostname and authorization cookie, this 'cookie' is in the hostname
    /var/lib/tor
    looks like this:
    newtorsitenamehere.onion yourauthcookieherebruh # client: IRCvisitor

    now remember in the torrc file below the port you created the 'IRCvisitor'
    without this information from /var/lib/tor added to the torrc file in the example
    above you cannot access the irc server or if it were http you can not access it
    even from the box hosting the irc/http server
    the advantage to stealth mode is this: it is NOT listed in the tor directory
    and if anything goes wrong with your irc server or you just want to create another openssl req -x509 -sha256 -newkey rsa:2048 -keyout ~/d0wnz/ircpriv.pem -out ~/d0wnz/ircert.pem -days 1024 -nodes -subj '/CN=irc.z4ojdtiaqvdfi4ys.onion'
    'domain' no problem, you are not tied to anything, and anyone accessing your site/chat
    has to have contacted you to get the authorization cookie

    from hidircz directory...
    # openssl req -x509 -sha256 -newkey rsa:2048 -keyout /root/hidrircz/ircpriv.pem -out /root/hidircz/ircert.pem -days 1024 -nodes -subj '/CN=irc.newtorsitenamehere.onion'
    # cat /root/hidircz/ircpriv.pem > hidz.pem
    # cat /root/hidircz/ircert.pem >> hidz.pem

    here's the python script....
    #################################

    #! /usr/bin/env python
    # https://github.com/jrosdahl/miniircd
    # Joel Rosdahl <joel@rosdahl.net>
    # pacman -S python-pyopenssl if needed

    import logging
    import os
    import re
    import select
    import socket
    import string
    import sys
    import tempfile
    import time
    from datetime import datetime
    from logging.handlers import RotatingFileHandler
    from optparse import OptionParser

    VERSION = "1.2.1"


    PY3 = sys.version_info[0] >= 3

    if PY3:
        def buffer_to_socket(msg):
            return msg.encode()

        def socket_to_buffer(buf):
            return buf.decode()
    else:
        def buffer_to_socket(msg):
            return msg

        def socket_to_buffer(buf):
            return buf


    def create_directory(path):
        if not os.path.isdir(path):
            os.makedirs(path)


    class Channel(object):
        def __init__(self, server, name):
            self.server = server
            self.name = name
            self.members = set()
            self._topic = ""
            self._key = None
            if self.server.state_dir:
                self._state_path = "%s/%s" % (
                    self.server.state_dir,
                    name.replace("_", "__").replace("/", "_"))
                self._read_state()
            else:
                self._state_path = None

        def add_member(self, client):
            self.members.add(client)

        def get_topic(self):
            return self._topic

        def set_topic(self, value):
            self._topic = value
            self._write_state()

        topic = property(get_topic, set_topic)

        def get_key(self):
            return self._key

        def set_key(self, value):
            self._key = value
            self._write_state()

        key = property(get_key, set_key)

        def remove_client(self, client):
            self.members.discard(client)
            if not self.members:
                self.server.remove_channel(self)

        def _read_state(self):
            if not (self._state_path and os.path.exists(self._state_path)):
                return
            data = {}

            with open(self._state_path, "rb") as state_file:
                exec(state_file.read(), {}, data)

            self._topic = data.get("topic", "")
            self._key = data.get("key")

        def _write_state(self):
            if not self._state_path:
                return
            (fd, path) = tempfile.mkstemp(dir=os.path.dirname(self._state_path))
            fp = os.fdopen(fd, "w")
            fp.write("topic = %r\n" % self.topic)
            fp.write("key = %r\n" % self.key)
            fp.close()
            os.rename(path, self._state_path)


    class Client(object):
        __linesep_regexp = re.compile(r"\r?\n")
        # The RFC limit for nicknames is 9 characters, but what the heck.
        __valid_nickname_regexp = re.compile(
            r"^[][\`_^{|}A-Za-z][][\`_^{|}A-Za-z0-9-]{0,50}$")
        __valid_channelname_regexp = re.compile(
            r"^[+!][^\x00\x07\x0a\x0d ,:]{0,50}$")

        def __init__(self, server, socket):
            self.server = server
            self.socket = socket
            self.channels = {}  # irc_lower(Channel name) --> Channel
            self.nickname = None
            self.user = None
            self.realname = None
            (self.host, self.port) = socket.getpeername()
            self.__timestamp = time.time()
            self.__readbuffer = ""
            self.__writebuffer = ""
            self.__sent_ping = False
            if self.server.password:
                self.__handle_command = self.__pass_handler
            else:
                self.__handle_command = self.__registration_handler

        def get_prefix(self):
            return "%s!%s@%s" % (self.nickname, self.user, self.host)
        prefix = property(get_prefix)

        def check_aliveness(self):
            now = time.time()
            if self.__timestamp + 180 < now:
                self.disconnect("ping timeout")
                return
            if not self.__sent_ping and self.__timestamp + 90 < now:
                if self.__handle_command == self.__command_handler:
                    # Registered.
                    self.message("PING :%s" % self.server.name)
                    self.__sent_ping = True
                else:
                    # Not registered.
                    self.disconnect("ping timeout")

        def write_queue_size(self):
            return len(self.__writebuffer)

        def __parse_read_buffer(self):
            lines = self.__linesep_regexp.split(self.__readbuffer)
            self.__readbuffer = lines[-1]
            lines = lines[:-1]
            for line in lines:
                if not line:
                    # Empty line. Ignore.
                    continue
                x = line.split(" ", 1)
                command = x[0].upper()
                if len(x) == 1:
                    arguments = []
                else:
                    if len(x[1]) > 0 and x[1][0] == ":":
                        arguments = [x[1][1:]]
                    else:
                        y = x[1].split(" :", 1)
                        arguments = y[0].split()
                        if len(y) == 2:
                            arguments.append(y[1])
                self.__handle_command(command, arguments)

        def __pass_handler(self, command, arguments):
            server = self.server
            if command == "PASS":
                if len(arguments) == 0:
                    self.reply_461("PASS")
                else:
                    if arguments[0].lower() == server.password:
                        self.__handle_command = self.__registration_handler
                    else:
                        self.reply("464 :Password incorrect")
            elif command == "QUIT":
                self.disconnect("Client quit")
                return

        def __registration_handler(self, command, arguments):
            server = self.server
            if command == "NICK":
                if len(arguments) < 1:
                    self.reply("431 :No nickname given")
                    return
                nick = arguments[0]
                if server.get_client(nick):
                    self.reply("433 * %s :Nickname is already in use" % nick)
                elif not self.__valid_nickname_regexp.match(nick):
                    self.reply("432 * %s :Erroneous nickname" % nick)
                else:
                    self.nickname = nick
                    server.client_changed_nickname(self, None)
            elif command == "USER":
                if len(arguments) < 4:
                    self.reply_461("USER")
                    return
                self.user = arguments[0]
                self.realname = arguments[3]
            elif command == "QUIT":
                self.disconnect("Client quit")
                return
            if self.nickname and self.user:
                self.reply("001 %s :Hi, welcome to IRC" % self.nickname)
                self.reply("002 %s :Your host is %s, running version miniircd-%s"
                           % (self.nickname, server.name, VERSION))
                self.reply("003 %s :This server was created sometime"
                           % self.nickname)
                self.reply("004 %s %s miniircd-%s o o"
                           % (self.nickname, server.name, VERSION))
                self.send_lusers()
                self.send_motd()
                self.__handle_command = self.__command_handler

        def __send_names(self, arguments, for_join=False):
            server = self.server
            valid_channel_re = self.__valid_channelname_regexp
            if len(arguments) > 0:
                channelnames = arguments[0].split(",")
            else:
                channelnames = sorted(self.channels.keys())
            if len(arguments) > 1:
                keys = arguments[1].split(",")
            else:
                keys = []
            keys.extend((len(channelnames) - len(keys)) * [None])
            for (i, channelname) in enumerate(channelnames):
                if for_join and irc_lower(channelname) in self.channels:
                    continue
                if not valid_channel_re.match(channelname):
                    self.reply_403(channelname)
                    continue
                channel = server.get_channel(channelname)
                if channel.key is not None and channel.key != keys:
                    self.reply(
                        "475 %s %s :Cannot join channel (+k) - bad key"
                        % (self.nickname, channelname))
                    continue

                if for_join:
                    channel.add_member(self)
                    self.channels[irc_lower(channelname)] = channel
                    self.message_channel(channel, "JOIN", channelname, True)
                    self.channel_log(channel, "joined", meta=True)
                    if channel.topic:
                        self.reply("332 %s %s :%s"
                                   % (self.nickname, channel.name, channel.topic))
                    else:
                        self.reply("331 %s %s :No topic is set"
                                   % (self.nickname, channel.name))
                names_prefix = "353 %s = %s :" % (self.nickname, channelname)
                names = ""
                # Max length: reply prefix ":server_name(space)" plus CRLF in
                # the end.
                names_max_len = 512 - (len(server.name) + 2 + 2)
                for name in sorted(x.nickname for x in channel.members):
                    if not names:
                        names = names_prefix + name
                    # Using >= to include the space between "names" and "name".
                    elif len(names) + len(name) >= names_max_len:
                        self.reply(names)
                        names = names_prefix + name
                    else:
                        names += " " + name
                if names:
                    self.reply(names)
                self.reply("366 %s %s :End of NAMES list"
                           % (self.nickname, channelname))

        def __command_handler(self, command, arguments):
            def away_handler():
                pass

            def ison_handler():
                if len(arguments) < 1:
                    self.reply_461("ISON")
                    return
                nicks = arguments
                online = [n for n in nicks if server.get_client(n)]
                self.reply("303 %s :%s" % (self.nickname, " ".join(online)))

            def join_handler():
                if len(arguments) < 1:
                    self.reply_461("JOIN")
                    return
                if arguments[0] == "0":
                    for (channelname, channel) in self.channels.items():
                        self.message_channel(channel, "PART", channelname, True)
                        self.channel_log(channel, "left", meta=True)
                        server.remove_member_from_channel(self, channelname)
                    self.channels = {}
                    return
                self.__send_names(arguments, for_join=True)

            def list_handler():
                if len(arguments) < 1:
                    channels = server.channels.values()
                else:
                    channels = []
                    for channelname in arguments[0].split(","):
                        if server.has_channel(channelname):
                            channels.append(server.get_channel(channelname))

                sorted_channels = sorted(channels, key=lambda x: x.name)
                for channel in sorted_channels:
                    self.reply("322 %s %s %d :%s"
                               % (self.nickname, channel.name,
                                  len(channel.members), channel.topic))
                self.reply("323 %s :End of LIST" % self.nickname)

            def lusers_handler():
                self.send_lusers()

            def mode_handler():
                if len(arguments) < 1:
                    self.reply_461("MODE")
                    return
                targetname = arguments[0]
                if server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    if len(arguments) < 2:
                        if channel.key:
                            modes = "+k"
                            if irc_lower(channel.name) in self.channels:
                                modes += " %s" % channel.key
                        else:
                            modes = "+"
                        self.reply("324 %s %s %s"
                                   % (self.nickname, targetname, modes))
                        return
                    flag = arguments[1]
                    if flag == "+k":
                        if len(arguments) < 3:
                            self.reply_461("MODE")
                            return
                        key = arguments[2]
                        if irc_lower(channel.name) in self.channels:
                            channel.key = key
                            self.message_channel(
                                channel, "MODE", "%s +k %s" % (channel.name, key),
                                True)
                            self.channel_log(
                                channel, "set channel key to %s" % key, meta=True)
                        else:
                            self.reply("442 %s :You're not on that channel"
                                       % targetname)
                    elif flag == "-k":
                        if irc_lower(channel.name) in self.channels:
                            channel.key = None
                            self.message_channel(
                                channel, "MODE", "%s -k" % channel.name,
                                True)
                            self.channel_log(
                                channel, "removed channel key", meta=True)
                        else:
                            self.reply("442 %s :You're not on that channel"
                                       % targetname)
                    else:
                        self.reply("472 %s %s :Unknown MODE flag"
                                   % (self.nickname, flag))
                elif targetname == self.nickname:
                    if len(arguments) == 1:
                        self.reply("221 %s +" % self.nickname)
                    else:
                        self.reply("501 %s :Unknown MODE flag" % self.nickname)
                else:
                    self.reply_403(targetname)

            def motd_handler():
                self.send_motd()

            def names_handler():
                self.__send_names(arguments)

            def nick_handler():
                if len(arguments) < 1:
                    self.reply("431 :No nickname given")
                    return
                newnick = arguments[0]
                client = server.get_client(newnick)
                if newnick == self.nickname:
                    pass
                elif client and client is not self:
                    self.reply("433 %s %s :Nickname is already in use"
                               % (self.nickname, newnick))
                elif not self.__valid_nickname_regexp.match(newnick):
                    self.reply("432 %s %s :Erroneous Nickname"
                               % (self.nickname, newnick))
                else:
                    for x in self.channels.values():
                        self.channel_log(
                            x, "changed nickname to %s" % newnick, meta=True)
                    oldnickname = self.nickname
                    self.nickname = newnick
                    server.client_changed_nickname(self, oldnickname)
                    self.message_related(
                        ":%s!%s@%s NICK %s"
                        % (oldnickname, self.user, self.host, self.nickname),
                        True)

            def notice_and_privmsg_handler():
                if len(arguments) == 0:
                    self.reply("411 %s :No recipient given (%s)"
                               % (self.nickname, command))
                    return
                if len(arguments) == 1:
                    self.reply("412 %s :No text to send" % self.nickname)
                    return
                targetname = arguments[0]
                message = arguments[1]
                client = server.get_client(targetname)
                if client:
                    client.message(":%s %s %s :%s"
                                   % (self.prefix, command, targetname, message))
                elif server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    self.message_channel(
                        channel, command, "%s :%s" % (channel.name, message))
                    self.channel_log(channel, message)
                else:
                    self.reply("401 %s %s :No such nick/channel"
                               % (self.nickname, targetname))

            def part_handler():
                if len(arguments) < 1:
                    self.reply_461("PART")
                    return
                if len(arguments) > 1:
                    partmsg = arguments[1]
                else:
                    partmsg = self.nickname
                for channelname in arguments[0].split(","):
                    if not valid_channel_re.match(channelname):
                        self.reply_403(channelname)
                    elif not irc_lower(channelname) in self.channels:
                        self.reply("442 %s %s :You're not on that channel"
                                   % (self.nickname, channelname))
                    else:
                        channel = self.channels[irc_lower(channelname)]
                        self.message_channel(
                            channel, "PART", "%s :%s" % (channelname, partmsg),
                            True)
                        self.channel_log(channel, "left (%s)" % partmsg, meta=True)
                        del self.channels[irc_lower(channelname)]
                        server.remove_member_from_channel(self, channelname)

            def ping_handler():
                if len(arguments) < 1:
                    self.reply("409 %s :No origin specified" % self.nickname)
                    return
                self.reply("PONG %s :%s" % (server.name, arguments[0]))

            def pong_handler():
                pass

            def quit_handler():
                if len(arguments) < 1:
                    quitmsg = self.nickname
                else:
                    quitmsg = arguments[0]
                self.disconnect(quitmsg)

            def topic_handler():
                if len(arguments) < 1:
                    self.reply_461("TOPIC")
                    return
                channelname = arguments[0]
                channel = self.channels.get(irc_lower(channelname))
                if channel:
                    if len(arguments) > 1:
                        newtopic = arguments[1]
                        channel.topic = newtopic
                        self.message_channel(
                            channel, "TOPIC", "%s :%s" % (channelname, newtopic),
                            True)
                        self.channel_log(
                            channel, "set topic to %r" % newtopic, meta=True)
                    else:
                        if channel.topic:
                            self.reply("332 %s %s :%s"
                                       % (self.nickname, channel.name,
                                          channel.topic))
                        else:
                            self.reply("331 %s %s :No topic is set"
                                       % (self.nickname, channel.name))
                else:
                    self.reply("442 %s :You're not on that channel" % channelname)

            def wallops_handler():
                if len(arguments) < 1:
                    self.reply_461("WALLOPS")
                    return
                message = arguments[0]
                for client in server.clients.values():
                    client.message(":%s NOTICE %s :Global notice: %s"
                                   % (self.prefix, client.nickname, message))

            def who_handler():
                if len(arguments) < 1:
                    return
                targetname = arguments[0]
                if server.has_channel(targetname):
                    channel = server.get_channel(targetname)
                    for member in channel.members:
                        self.reply("352 %s %s %s %s %s %s H :0 %s"
                                   % (self.nickname, targetname, member.user,
                                      member.host, server.name, member.nickname,
                                      member.realname))
                    self.reply("315 %s %s :End of WHO list"
                               % (self.nickname, targetname))

            def whois_handler():
                if len(arguments) < 1:
                    return
                username = arguments[0]
                user = server.get_client(username)
                if user:
                    self.reply("311 %s %s %s %s * :%s"
                               % (self.nickname, user.nickname, user.user,
                                  user.host, user.realname))
                    self.reply("312 %s %s %s :%s"
                               % (self.nickname, user.nickname, server.name,
                                  server.name))
                    self.reply("319 %s %s :%s"
                               % (self.nickname, user.nickname,
                                  " ".join(user.channels)))
                    self.reply("318 %s %s :End of WHOIS list"
                               % (self.nickname, user.nickname))
                else:
                    self.reply("401 %s %s :No such nick"
                               % (self.nickname, username))

            handler_table = {
                "AWAY": away_handler,
                "ISON": ison_handler,
                "JOIN": join_handler,
                "LIST": list_handler,
                "LUSERS": lusers_handler,
                "MODE": mode_handler,
                "MOTD": motd_handler,
                "NAMES": names_handler,
                "NICK": nick_handler,
                "NOTICE": notice_and_privmsg_handler,
                "PART": part_handler,
                "PING": ping_handler,
                "PONG": pong_handler,
                "PRIVMSG": notice_and_privmsg_handler,
                "QUIT": quit_handler,
                "TOPIC": topic_handler,
                "WALLOPS": wallops_handler,
                "WHO": who_handler,
                "WHOIS": whois_handler,
            }
            server = self.server
            valid_channel_re = self.__valid_channelname_regexp
            try:
                handler_table[command]()
            except KeyError:
                self.reply("421 %s %s :Unknown command" % (self.nickname, command))

        def socket_readable_notification(self):
            try:
                data = self.socket.recv(2 ** 10)
                self.server.print_debug(
                    "[%s:%d] -> %r" % (self.host, self.port, data))
                quitmsg = "EOT"
            except socket.error as x:
                data = ""
                quitmsg = x
            if data:
                self.__readbuffer += socket_to_buffer(data)
                self.__parse_read_buffer()
                self.__timestamp = time.time()
                self.__sent_ping = False
            else:
                self.disconnect(quitmsg)

        def socket_writable_notification(self):
            try:
                sent = self.socket.send(buffer_to_socket(self.__writebuffer))
                self.server.print_debug(
                    "[%s:%d] <- %r" % (
                        self.host, self.port, self.__writebuffer[:sent]))
                self.__writebuffer = self.__writebuffer[sent:]
            except socket.error as x:
                self.disconnect(x)

        def disconnect(self, quitmsg):
            self.message("ERROR :%s" % quitmsg)
            self.server.print_info(
                "Disconnected connection from %s:%s (%s)." % (
                    self.host, self.port, quitmsg))
            self.socket.close()
            self.server.remove_client(self, quitmsg)

        def message(self, msg):
            self.__writebuffer += msg + "\r\n"

        def reply(self, msg):
            self.message(":%s %s" % (self.server.name, msg))

        def reply_403(self, channel):
            self.reply("403 %s %s :No such channel" % (self.nickname, channel))

        def reply_461(self, command):
            nickname = self.nickname or "*"
            self.reply("461 %s %s :Not enough parameters" % (nickname, command))

        def message_channel(self, channel, command, message, include_self=False):
            line = ":%s %s %s" % (self.prefix, command, message)
            for client in channel.members:
                if client != self or include_self:
                    client.message(line)

        def channel_log(self, channel, message, meta=False):
            if not self.server.channel_log_dir:
                return
            if meta:
                format = "[%s] * %s %s\n"
            else:
                format = "[%s] <%s> %s\n"
            timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
            logname = channel.name.replace("_", "__").replace("/", "_")
            fp = open("%s/%s.log" % (self.server.channel_log_dir, logname), "a")
            fp.write(format % (timestamp, self.nickname, message))
            fp.close()

        def message_related(self, msg, include_self=False):
            clients = set()
            if include_self:
                clients.add(self)
            for channel in self.channels.values():
                clients |= channel.members
            if not include_self:
                clients.discard(self)
            for client in clients:
                client.message(msg)

        def send_lusers(self):
            self.reply("251 %s :There are %d users and 0 services on 1 server"
                       % (self.nickname, len(self.server.clients)))

        def send_motd(self):
            server = self.server
            motdlines = server.get_motd_lines()
            if motdlines:
                self.reply("375 %s :- %s Message of the day -"
                           % (self.nickname, server.name))
                for line in motdlines:
                    self.reply("372 %s :- %s" % (self.nickname, line.rstrip()))
                self.reply("376 %s :End of /MOTD command" % self.nickname)
            else:
                self.reply("422 %s :MOTD File is missing" % self.nickname)


    class Server(object):
        def __init__(self, options):
            self.ports = options.ports
            self.password = options.password
            self.ssl_pem_file = options.ssl_pem_file
            self.motdfile = options.motd
            self.verbose = options.verbose
            self.debug = options.debug
            self.channel_log_dir = options.channel_log_dir
            self.chroot = options.chroot
            self.setuid = options.setuid
            self.state_dir = options.state_dir
            self.log_file = options.log_file
            self.log_max_bytes = options.log_max_size * 1024 * 1024
            self.log_count = options.log_count
            self.logger = None

            if options.password_file:
                with open(options.password_file, "r") as fp:
                    self.password = fp.read().strip("\n")

            if self.ssl_pem_file:
                self.ssl = __import__("ssl")

            # Find certificate after daemonization if path is relative:
            if self.ssl_pem_file and os.path.exists(self.ssl_pem_file):
                self.ssl_pem_file = os.path.abspath(self.ssl_pem_file)
            # else: might exist in the chroot jail, so just continue

            if options.listen:
                self.address = socket.gethostbyname(options.listen)
            else:
                self.address = ""
            server_name_limit = 63  # From the RFC.
            self.name = socket.getfqdn(self.address)[:server_name_limit]

            self.channels = {}  # irc_lower(Channel name) --> Channel instance.
            self.clients = {}  # Socket --> Client instance.
            self.nicknames = {}  # irc_lower(Nickname) --> Client instance.
            if self.channel_log_dir:
                create_directory(self.channel_log_dir)
            if self.state_dir:
                create_directory(self.state_dir)

        def make_pid_file(self, filename):
            try:
                fd = os.open(filename, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644)
                os.write(fd, "%i\n" % os.getpid())
                os.close(fd)
            except:
                self.print_error("Could not create PID file %r" % filename)
                sys.exit(1)

        def daemonize(self):
            try:
                pid = os.fork()
                if pid > 0:
                    sys.exit(0)
            except OSError:
                sys.exit(1)
            os.setsid()
            try:
                pid = os.fork()
                if pid > 0:
                    self.print_info("PID: %d" % pid)
                    sys.exit(0)
            except OSError:
                sys.exit(1)
            os.chdir("/")
            os.umask(0)
            dev_null = open("/dev/null", "r+")
            os.dup2(dev_null.fileno(), sys.stdout.fileno())
            os.dup2(dev_null.fileno(), sys.stderr.fileno())
            os.dup2(dev_null.fileno(), sys.stdin.fileno())

        def get_client(self, nickname):
            return self.nicknames.get(irc_lower(nickname))

        def has_channel(self, name):
            return irc_lower(name) in self.channels

        def get_channel(self, channelname):
            if irc_lower(channelname) in self.channels:
                channel = self.channels[irc_lower(channelname)]
            else:
                channel = Channel(self, channelname)
                self.channels[irc_lower(channelname)] = channel
            return channel

        def get_motd_lines(self):
            if self.motdfile:
                try:
                    return open(self.motdfile).readlines()
                except IOError:
                    return ["Could not read MOTD file %r." % self.motdfile]
            else:
                return []

        def print_info(self, msg):
            if self.verbose:
                print(msg)
                sys.stdout.flush()
            if self.logger:
                self.logger.info(msg)

        def print_debug(self, msg):
            if self.debug:
                print(msg)
                sys.stdout.flush()
            if self.logger:
                self.logger.debug(msg)

        def print_error(self, msg):
            sys.stderr.write("%s\n" % msg)
            if self.logger:
                self.logger.error(msg)

        def client_changed_nickname(self, client, oldnickname):
            if oldnickname:
                del self.nicknames[irc_lower(oldnickname)]
            self.nicknames[irc_lower(client.nickname)] = client

        def remove_member_from_channel(self, client, channelname):
            if irc_lower(channelname) in self.channels:
                channel = self.channels[irc_lower(channelname)]
                channel.remove_client(client)

        def remove_client(self, client, quitmsg):
            client.message_related(":%s QUIT :%s" % (client.prefix, quitmsg))
            for x in client.channels.values():
                client.channel_log(x, "quit (%s)" % quitmsg, meta=True)
                x.remove_client(client)
            if client.nickname \
                    and irc_lower(client.nickname) in self.nicknames:
                del self.nicknames[irc_lower(client.nickname)]
            del self.clients[client.socket]

        def remove_channel(self, channel):
            del self.channels[irc_lower(channel.name)]

        def start(self):
            serversockets = []
            for port in self.ports:
                s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
                s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
                try:
                    s.bind((self.address, port))
                except socket.error as e:
                    self.print_error("Could not bind port %s: %s." % (port, e))
                    sys.exit(1)
                s.listen(5)
                serversockets.append(s)
                del s
                self.print_info("Listening on port %d." % port)
            if self.chroot:
                os.chdir(self.chroot)
                os.chroot(self.chroot)
                self.print_info("Changed root directory to %s" % self.chroot)
            if self.setuid:
                os.setgid(self.setuid[1])
                os.setuid(self.setuid[0])
                self.print_info("Setting uid:gid to %s:%s"
                                % (self.setuid[0], self.setuid[1]))

            self.init_logging()
            try:
                self.run(serversockets)
            except:
                if self.logger:
                    self.logger.exception("Fatal exception")
                raise

        def init_logging(self):
            if not self.log_file:
                return

            log_level = logging.INFO
            if self.debug:
                log_level = logging.DEBUG
            self.logger = logging.getLogger("miniircd")
            formatter = logging.Formatter(
                ("%(asctime)s - %(name)s[%(process)d] - "
                 "%(levelname)s - %(message)s"))
            fh = RotatingFileHandler(
                self.log_file,
                maxBytes=self.log_max_bytes,
                backupCount=self.log_count)
            fh.setLevel(log_level)
            fh.setFormatter(formatter)
            self.logger.setLevel(log_level)
            self.logger.addHandler(fh)

        def run(self, serversockets):
            last_aliveness_check = time.time()
            while True:
                (iwtd, owtd, ewtd) = select.select(
                    serversockets + [x.socket for x in self.clients.values()],
                    [x.socket for x in self.clients.values()
                     if x.write_queue_size() > 0],
                    [],
                    10)
                for x in iwtd:
                    if x in self.clients:
                        self.clients[x].socket_readable_notification()
                    else:
                        (conn, addr) = x.accept()
                        if self.ssl_pem_file:
                            try:
                                conn = self.ssl.wrap_socket(
                                    conn,
                                    server_side=True,
                                    certfile=self.ssl_pem_file,
                                    keyfile=self.ssl_pem_file)
                            except Exception as e:
                                self.print_error(
                                    "SSL error for connection from %s:%s: %s" % (
                                        addr[0], addr[1], e))
                                continue
                        try:
                            self.clients[conn] = Client(self, conn)
                            self.print_info("Accepted connection from %s:%s." % (
                                addr[0], addr[1]))
                        except socket.error as e:
                            try:
                                conn.close()
                            except:
                                pass
                for x in owtd:
                    if x in self.clients:  # client may have been disconnected
                        self.clients[x].socket_writable_notification()
                now = time.time()
                if last_aliveness_check + 10 < now:
                    for client in list(self.clients.values()):
                        client.check_aliveness()
                    last_aliveness_check = now


    _maketrans = str.maketrans if PY3 else string.maketrans
    _ircstring_translation = _maketrans(
        string.ascii_lowercase.upper() + "[]\\^",
        string.ascii_lowercase + "{}|~")


    def irc_lower(s):
        return s.translate(_ircstring_translation)


    def main(argv):
        op = OptionParser(
            version=VERSION,
            description="miniircd is a small and limited IRC server.")
        op.add_option(
            "--channel-log-dir",
            metavar="X",
            help="store channel log in directory X")
        op.add_option(
            "-d", "--daemon",
            action="store_true",
            help="fork and become a daemon")
        op.add_option(
            "--debug",
            action="store_true",
            help="print debug messages to stdout")
        op.add_option(
            "--listen",
            metavar="X",
            help="listen on specific IP address X")
        op.add_option(
            "--log-count",
            metavar="X", default=10, type="int",
            help="keep X log files; default: %default")
        op.add_option(
            "--log-file",
            metavar="X",
            help="store log in file X")
        op.add_option(
            "--log-max-size",
            metavar="X", default=10, type="int",
            help="set maximum log file size to X MiB; default: %default MiB")
        op.add_option(
            "--motd",
            metavar="X",
            help="display file X as message of the day")
        op.add_option(
            "--pid-file",
            metavar="X",
            help="write PID to file X")
        op.add_option(
            "-p", "--password",
            metavar="X",
            help="require connection password X; default: no password")
        op.add_option(
            "--password-file",
            metavar="X",
            help=("require connection password stored in file X;"
                  " default: no password"))
        op.add_option(
            "--ports",
            metavar="X",
            help="listen to ports X (a list separated by comma or whitespace);"
                 " default: 6667 or 6697 if SSL is enabled")
        op.add_option(
            "-s", "--ssl-pem-file",
            metavar="FILE",
            help="enable SSL and use FILE as the .pem certificate+key")
        op.add_option(
            "--state-dir",
            metavar="X",
            help="save persistent channel state (topic, key) in directory X")
        op.add_option(
            "--verbose",
            action="store_true",
            help="be verbose (print some progress messages to stdout)")
        if os.name == "posix":
            op.add_option(
                "--chroot",
                metavar="X",
                help="change filesystem root to directory X after startup"
                     " (requires root)")
            op.add_option(
                "--setuid",
                metavar="U[:G]",
                help="change process user (and optionally group) after startup"
                     " (requires root)")
        else:
            op.chroot = False
            op.setuid = False

        (options, args) = op.parse_args(argv[1:])
        if options.debug:
            options.verbose = True
        if options.ports is None:
            if options.ssl_pem_file is None:
                options.ports = "6667"
            else:
                options.ports = "6697"
        if options.chroot:
            if os.getuid() != 0:
                op.error("Must be root to use --chroot")
        if options.setuid:
            from pwd import getpwnam
            from grp import getgrnam
            if os.getuid() != 0:
                op.error("Must be root to use --setuid")
            matches = options.setuid.split(":")
            if len(matches) == 2:
                options.setuid = (getpwnam(matches[0]).pw_uid,
                                  getgrnam(matches[1]).gr_gid)
            elif len(matches) == 1:
                options.setuid = (getpwnam(matches[0]).pw_uid,
                                  getpwnam(matches[0]).pw_gid)
            else:
                op.error("Specify a user, or user and group separated by a colon,"
                         " e.g. --setuid daemon, --setuid nobody:nobody")
        if (os.getuid() == 0 or os.getgid() == 0) and not options.setuid:
            op.error("Running this service as root is not recommended. Use the"
                     " --setuid option to switch to an unprivileged account after"
                     " startup. If you really intend to run as root, use"
                     " \"--setuid root\".")

        ports = []
        for port in re.split(r"[,\s]+", options.ports):
            try:
                ports.append(int(port))
            except ValueError:
                op.error("bad port: %r" % port)
        options.ports = ports
        server = Server(options)
        if options.daemon:
            server.daemonize()
        if options.pid_file:
            server.make_pid_file(options.pid_file)
        try:
            server.start()
        except KeyboardInterrupt:
            server.print_error("Interrupted.")


    main(sys.argv)

    #################################

    top of the script don't think needed just in case
    ya might add 'import ssl'
    on github the python file is named a bit different
    to start the script save it as example: minircd.py
    chmod +x the script

    as root from hidircz directory with your pem file and motd file:
    # python minircd.py --ssl-pem-file=/root/hidircz/hidz.pem --listen 127.0.0.1 --motd=huh.motd --setuid=root

    i didn't test this out but to run the script as non root ya might need change directory to say /home/nonrootuser
    move everything there, chown -R nonroot:nonroot all the files
    so ssl doesn't gripe about an error i might be wrong on this fyi

    to get help with the irc server:
    # python minircd.py -h

    i forgot to mention to start tor at least on arch:
    # /usr/bin/tor -f /etc/tor/torrc

    so now you have a irc tor chat server up in stealth mode
    plus an additional layer of ssl

    the clients say via irssi can connect as follows:
    # socat TCP4-LISTEN:8000,reuseaddr,fork SOCKS4a:127.0.0.1:newtorsitenamehere.onion:6697,socksport=9050

    you don't add the 'irc' in front of the 'domain' just the onion address without 'irc'

    then launch irssi and to connect
    /connect -ssl 127.0.0.1 8000

    you can create a room join chat typical irc stuff
    anything done as /whois will show localhost no ip info

    for pidgin users little different but not much...
    basic tab is irc protocol
    yer user name
    server is the tor address without 'irc'
    advanced tab
    port 6697
    proxy tab...
    proxy is http
    host 127.0.0.1 port 8118

    start privoxy before connecting:
    # /usr/bin/privoxy --no-daemon /etc/privoxy/config

    here is my privoxy config:
    #######################################

    # Generally, this file goes in /etc/privoxy/config
    # unfucked config by cm0s 010117
    # to start /usr/bin/privoxy --no-dameon /etc/privoxy/config
    # Tor listens as a SOCKS4a proxy here:
    forward-socks5 / 127.0.0.1:9050 .

    # confz
    confdir /etc/privoxy
    logdir /var/log/privoxy
    # actionsfile standard  # Internal purpose, recommended
    actionsfile default.action   # Main actions file
    actionsfile user.action      # User customizations
    filterfile default.filter

    # timeout shit
    keep-alive-timeout 600
    # mohr timeout shit
    default-server-timeout 600
    # yet mohhhrrr...
    socket-timeout 600

    # Don't log interesting things, only startup messages, warnings and errors
    logfile logfile
    #jarfile jarfile
    #debug   0    # show each GET/POST/CONNECT request
    debug   4096 # Startup banner and warnings
    debug   8192 # Errors - *we highly recommended enabling this*

    user-manual /usr/share/doc/privoxy/user-manual
    listen-address  localhost:8118
    toggle  1
    enable-remote-toggle 0
    enable-edit-actions 0
    enable-remote-http-toggle 0
    buffer-limit 4096
    #
    #
    ########################################

    a quick side note:
    make sure logging is off in pidgin and also the otr plugin

    so recap, ya just launched your very own irc chat server
    can make your own motd, publish your otr key add whatever custom
    stuff ya want and ya really made it private coz it's in stealth mode
    stealth mode tor is NOT listed in the tor directory and even if someone
    finds your onion address they can't do anything, won't even let them
    scan your address without the auth cookie, and you added another layer of ssl

    cheerz

    splif
     


  6. hey NoiselessOwl hope all is well

     

    your english is fine, better than mine actually

     

    i might be wrong on this had to do some googling

     

    i am guessing what you are wanting is called 'split tunneling'

     

    ref: https://airvpn.org/topic/20695-split-tunneling/

     

    from what i understand from that post you need iptables to help

     

    you with your routing so if an emergency happens and you are able

     

    to make a 911 call they have your geo location.

     

     


  7. see if this makes a diff as your duckduckgo home page:

    https://duckduckgo.com/?kf=fw&kh=1&k1=-1
    

    basically shutting some of the junk off

     

     

    some css to darken duckduckgo:

     

    /*
    about:config
    search stylish set
    editor to 1
    dux 041617 css edit
    @-moz-document domain("3g2upl4pq6kufc4m.onion")
    non java/java pages look same now
    unfuxd 
    */
    
        @-moz-document domain("duckduckgo.com") {
            
        /* custom colors */             /*var(--alt-bg)*/
        :root {
        --main-bg: #111 !important;              
        --dark-bg: #111 !important;                
        --darker-bg: #222 !important;              
        --header-bg: #111 !important;                
        --main-text: #999 !important;      
        --yellow-text: #8a7b70 !important;    
        --blue-text: #556b82 !important;      
        --green-text: #74857c !important;      
        }      
    
    .header.header--html {
        width: 100%;
        max-width: none;
        box-sizing: border-box;
        padding: 16px 0px 10px;
        border-bottom: 1px solid #111111 !important;
        border-top: 2px solid #111111 !important;
        display: block;
    }
    
    .search-filters-wrap {display:none;}
    
    .js-sidebar-modules {
        display: none;
    }
    
    .result--ad--double {
        float: left;
        width: 50%;
        display: none;
    }
    
    .nav-menu--slideout {display:none !important;}
    
    .onboarding-ed {display:none !important;}
    
    .js-sidebar-ads {display:none !important;}
    
    #ads {
        display: none !important;
    }
    
    .search:hover .search__clear, .search__input:focus ~ .search__clear, .search--header.has-text.search--hover .search__clear, .search--header.has-text.search--focus .search__clear, .search--home.has-text .search__clear {
        visibility: visible;
        opacity: 0.9;
        display: none !important;
    }
    
    .onboarding-bottom-balloonist {
        height: auto;
        text-align: center;
        overflow: hidden;
        background: transparent -moz-linear-gradient(center top , #5090C7 0%, #5396CA 5%, #5AA7D1 15%, #64BDDB 50%, #FFF9DB 85%, #FFF 100%) repeat scroll 0% 0%;
        display: none !important;
    }
    .onboarding-bottom {
        display: none !important;
    }
    .onboarding-bottom {
        width: 100%;
        position: absolute;
        top: 100%;
        height: 100%;
        min-height: 450px;
        overflow: hidden;
        display: none !important;
    }
    
    .search__autocomplete {
        display: none !important;
        position: absolute;
        top: 2.8em;
        left: 0px;
        width: 100%;
        max-height: 208px;
        border: 1px solid #D0D0D0;
        border-radius: 0px 0px 2px 2px;
        margin-top: -2px;
        ;
        margin-right: -1px;
        z-index: 25;
        box-shadow: 0px 2px 4px rgba(0, 0, 0, 0.1);
    }
    
    .navbutton {
        background-color: transparent;
        border-width: 0px 0px 1px;
        border-style: none none solid;
        border-color: -moz-use-text-color -moz-use-text-color transparent;
        -moz-border-top-colors: none;
        -moz-border-right-colors: none;
        -moz-border-bottom-colors: none;
        -moz-border-left-colors: none;
        border-image: none;
        cursor: pointer;
        font-size: 12px;
        font-weight: bold;
        text-decoration: underline;
        color: #1168CC;
        padding: 0px;
    }
    
    .header-atb, .header-atb:hover, .header-atb:visited, .header-atb:active {
        color: #333;
        text-decoration: none;
        display: none;
    }
    
    .results--powered__badge.badge--yahoo {
        bottom: -1px;
        display: none;
    }
      
    .header {
        font-size: 32px;
        font-weight: bold;
        color: #DC5E47;
        display: none;
    }
    
    .submit {
        height: 40px;
        font-size: 20px;
        cursor: pointer;
        display: none;
    }
    
    .results--powered a, .results--powered a:visited {
        color: inherit;
        font-size: 0.9em;
        display: none;
    }
    
    .results--sidebar--mid .btn--top {
        position: absolute;
        right: -64px;
        top: 24px;
        display: none;
    }
    
        .logo_homepage {
            background-image: url("assets/logo_homepage_mobile.normal.v107.png");
            background-size: 275px 62px;
            width: 275px;
            height: 62px;
            display: none;
        }
    
    .result-snippet {
        font-size: 100%;
        color: #777777;
    }
    
    link-text {
        color: #666999;
        font-size: 100%;
    }
    
    .frm__select {
        margin-right: 5px;
        display: none;
    }
    
    .query {
        border-color: rgb(85, 85, 85);
        border-style: solid;
        border-width: 1px;
        border-radius: 3px;
        font-size: 20px;
        padding: 5px 6px;
        text-align: left;
        width: 60%;
        max-width: 600px;
        height: 28px;
        background-color: #222333;
    }
         
        .header__logo-wrap {
            position: absolute;
            left: 0px;
            margin-top: -10px;
            width: 94px;
            height: 60px;
            display: none;
        }
    
    .frm_select {
           display: none;
    }
         
        .zci-wrap {
            background-color: #F2F2F2;
            clear: both;
            display: none;
            position: relative;
            z-index: 10;
            margin-top: -1px;
        }
         
        .tile-wrap {
            position: relative;
            top: 0px;
            margin-top: 0px;
            margin-bottom: 0px;
            display: none;
        }
         
        .zci-wrapper {
            background-color: #F2F2F2;
            padding: 20px 0px 20px 104px;
            border-bottom: 1px solid #D0D0D0;
            line-height: 1.45;
            display: none;
        }
                                       /* bgcolor */
        body, .result__body, .modal--region-filter .modal__list__link.is-highlighted {
          background-color: var(--main-bg) !important;
            }
          
          .search__button:hover, .acp-wrap, .result__body:hover, .tileview .metabar--fixed, .tile-wrap, .tileview--grid, .is-stuck, .modal--region-filter .frm__input, .switch {
            background: var(--dark-bg) !important;
          }  
          
          a, .acp-wrap, .result__snippet {
            color: var(--main-text) !important;
          }  
          
        .nav-menu__item > a, .zcm__link, .result__url, .result__snippet b, .result__snippet strong, div.tile, .frm__input {
            color: var(--green-text) !important;
          }  
          
          .search__input, .search__input--adv, .result__a, .tile__title, .modal__box {
            color: var(--blue-text) !important;
          }
         
        .header-wrap--home, .header-wrap, .zcm__link.is-active {
            border-color: var(--main-bg) !important;
          }  
          
          .site-wrapper-border {
            background: transparent !important;
          }  
          
          .switch__knob, .tile-nav.can-scroll {
            background: var(--main-text) !important;
          }  
          
          .search, .search--adv, .nav-menu, .nav-menu--slideout, .search--home.has-text .search__button, div.acp:hover, .header-wrap, #back-to-top, .result--sep--hr::before, .tile__body, .tile--s, .tile--info, .mapview__close, .metabar__mode, .modal--popout .modal__box, .modal__header, .search:hover .search__button, .search__input:focus ~ .search__button, .search--header.has-text.search--hover .search__button, .search--header.has-text.search--focus .search__button, .search--home.has-text .search__button {
            background-color: var(--darker-bg) !important;
          }  
          
          .search, .search--adv, .acp-wrap, .search__autocomplete, .zci.is-active, .tile, .is-stuck, .modal--region-filter .frm__input, .modal__header {
            border: none !important;
          }  
          
          .search, .search--adv, .tile {
            box-shadow: 2px 2px 4px 2px rgba(0,0,0,0.2) !important;
          }  
          
          .tag-home, .badge-link, .logo_homepage__tt, #duckbar_static_sep, #duckbar_dynamic_sep, .feedback-btn, .attribution--link__icon {
            display: none !important;
          }
          
          .svg .logo_homepage {
                background-image: url("http://puu.sh/o6X09/a27acc920a.png") !important;
        }
          
          .svg .header__logo {
            background-image: url("http://puu.sh/o6YKu/01ea108997.png") !important;
          }  
         
        .header--aside, a.search-filter__icon {
            opacity: 0 !important;
          }  
          
        .header--aside:hover, a.search-filter__icon:hover {
            opacity: 0.7 !important;
          }    
          
          a, body, .result__snippet, .search__input, .search__input--adv {
            font-size: 14px !important;
            font-family: open sans !important;
          }  
          
        }  
    
    

    i put their onion url in there also at the top commented out

     

    google is an ad company but like everyone else i like their searches and like the results with a clean layout



  8. # airvpn irc hidden service stealth mode ssl

    # mkdir hidircz
    # cd d0wnz
    # touch cool.motd
    # vim cool.motd
    hit 'i' copy paste
    text below or your own
    custom motd
    hit 'esc' key then type ':wq'
    ____ _ ____ _ _ ___ _ _
    |__| | |__/ | | |__] |\ |
    | | | | \ \/ | | \|
    ===========================
    https://airvpn.org

    add this to your torrc file
    mod for your own config if needed...

    VirtualAddrNetwork 10.192.0.0/10
    TransPort 9040
    DNSPort 53
    AutomapHostsOnResolve 1

    ##hidden service
    HiddenServiceDir /var/lib/tor/
    HiddenServicePort 6697 127.0.0.1:6697
    HiddenServiceAuthorizeClient stealth IRCvisitor
    HidServAuth newtorsitenamehere.onion stealthpasshere

    you'll start tor and then stop tor to get your hidden service
    hostname and authorization cookie, this 'cookie' is in the hostname
    /var/lib/tor
    looks like this:
    newtorsitenamehere.onion yourauthcookieherebruh # client: IRCvisitor

    now remember in the torrc file below the port you created the 'IRCvisitor'
    without this information from /var/lib/tor added to the torrc file in the example
    above you cannot access the irc server or if it were http you can not access it
    even from the box hosting the irc/http server
    the advantage to stealth mode is this: it is NOT listed in the tor directory
    and if anything goes wrong with your irc server or you just want to create another openssl req -x509 -sha256 -newkey rsa:2048 -keyout ~/d0wnz/ircpriv.pem -out ~/d0wnz/ircert.pem -days 1024 -nodes -subj '/CN=irc.z4ojdtiaqvdfi4ys.onion'
    'domain' no problem, you are not tied to anything, and anyone accessing your site/chat
    has to have contacted you to get the authorization cookie

    from hidircz directory...
    # openssl req -x509 -sha256 -newkey rsa:2048 -keyout /root/hidrircz/ircpriv.pem -out /root/hidircz/ircert.pem -days 1024 -nodes -subj '/CN=irc.newtorsitenamehere.onion'
    # cat /root/hidircz/ircpriv.pem > hidz.pem
    # cat /root/hidircz/ircert.pem >> hidz.pem

    here's the python script....
    #################################

    #! /usr/bin/env python
    # https://github.com/jrosdahl/miniircd
    # Joel Rosdahl <joel@rosdahl.net>
    # pacman -S python-pyopenssl if needed

    import logging
    import os
    import re
    import select
    import socket
    import string
    import sys
    import tempfile
    import time
    from datetime import datetime
    from logging.handlers import RotatingFileHandler
    from optparse import OptionParser

    VERSION = "1.2.1"


    PY3 = sys.version_info[0] >= 3

    if PY3:
    def buffer_to_socket(msg):
    return msg.encode()

    def socket_to_buffer(buf):
    return buf.decode()
    else:
    def buffer_to_socket(msg):
    return msg

    def socket_to_buffer(buf):
    return buf


    def create_directory(path):
    if not os.path.isdir(path):
    os.makedirs(path)


    class Channel(object):
    def __init__(self, server, name):
    self.server = server
    self.name = name
    self.members = set()
    self._topic = ""
    self._key = None
    if self.server.state_dir:
    self._state_path = "%s/%s" % (
    self.server.state_dir,
    name.replace("_", "__").replace("/", "_"))
    self._read_state()
    else:
    self._state_path = None

    def add_member(self, client):
    self.members.add(client)

    def get_topic(self):
    return self._topic

    def set_topic(self, value):
    self._topic = value
    self._write_state()

    topic = property(get_topic, set_topic)

    def get_key(self):
    return self._key

    def set_key(self, value):
    self._key = value
    self._write_state()

    key = property(get_key, set_key)

    def remove_client(self, client):
    self.members.discard(client)
    if not self.members:
    self.server.remove_channel(self)

    def _read_state(self):
    if not (self._state_path and os.path.exists(self._state_path)):
    return
    data = {}

    with open(self._state_path, "rb") as state_file:
    exec(state_file.read(), {}, data)

    self._topic = data.get("topic", "")
    self._key = data.get("key")

    def _write_state(self):
    if not self._state_path:
    return
    (fd, path) = tempfile.mkstemp(dir=os.path.dirname(self._state_path))
    fp = os.fdopen(fd, "w")
    fp.write("topic = %r\n" % self.topic)
    fp.write("key = %r\n" % self.key)
    fp.close()
    os.rename(path, self._state_path)


    class Client(object):
    __linesep_regexp = re.compile(r"\r?\n")
    # The RFC limit for nicknames is 9 characters, but what the heck.
    __valid_nickname_regexp = re.compile(
    r"^[][\`_^{|}A-Za-z][][\`_^{|}A-Za-z0-9-]{0,50}$")
    __valid_channelname_regexp = re.compile(
    r"^[+!][^\x00\x07\x0a\x0d ,:]{0,50}$")

    def __init__(self, server, socket):
    self.server = server
    self.socket = socket
    self.channels = {} # irc_lower(Channel name) --> Channel
    self.nickname = None
    self.user = None
    self.realname = None
    (self.host, self.port) = socket.getpeername()
    self.__timestamp = time.time()
    self.__readbuffer = ""
    self.__writebuffer = ""
    self.__sent_ping = False
    if self.server.password:
    self.__handle_command = self.__pass_handler
    else:
    self.__handle_command = self.__registration_handler

    def get_prefix(self):
    return "%s!%s@%s" % (self.nickname, self.user, self.host)
    prefix = property(get_prefix)

    def check_aliveness(self):
    now = time.time()
    if self.__timestamp + 180 < now:
    self.disconnect("ping timeout")
    return
    if not self.__sent_ping and self.__timestamp + 90 < now:
    if self.__handle_command == self.__command_handler:
    # Registered.
    self.message("PING :%s" % self.server.name)
    self.__sent_ping = True
    else:
    # Not registered.
    self.disconnect("ping timeout")

    def write_queue_size(self):
    return len(self.__writebuffer)

    def __parse_read_buffer(self):
    lines = self.__linesep_regexp.split(self.__readbuffer)
    self.__readbuffer = lines[-1]
    lines = lines[:-1]
    for line in lines:
    if not line:
    # Empty line. Ignore.
    continue
    x = line.split(" ", 1)
    command = x[0].upper()
    if len(x) == 1:
    arguments = []
    else:
    if len(x[1]) > 0 and x[1][0] == ":":
    arguments = [x[1][1:]]
    else:
    y = x[1].split(" :", 1)
    arguments = y[0].split()
    if len(y) == 2:
    arguments.append(y[1])
    self.__handle_command(command, arguments)

    def __pass_handler(self, command, arguments):
    server = self.server
    if command == "PASS":
    if len(arguments) == 0:
    self.reply_461("PASS")
    else:
    if arguments[0].lower() == server.password:
    self.__handle_command = self.__registration_handler
    else:
    self.reply("464 :Password incorrect")
    elif command == "QUIT":
    self.disconnect("Client quit")
    return

    def __registration_handler(self, command, arguments):
    server = self.server
    if command == "NICK":
    if len(arguments) < 1:
    self.reply("431 :No nickname given")
    return
    nick = arguments[0]
    if server.get_client(nick):
    self.reply("433 * %s :Nickname is already in use" % nick)
    elif not self.__valid_nickname_regexp.match(nick):
    self.reply("432 * %s :Erroneous nickname" % nick)
    else:
    self.nickname = nick
    server.client_changed_nickname(self, None)
    elif command == "USER":
    if len(arguments) < 4:
    self.reply_461("USER")
    return
    self.user = arguments[0]
    self.realname = arguments[3]
    elif command == "QUIT":
    self.disconnect("Client quit")
    return
    if self.nickname and self.user:
    self.reply("001 %s :Hi, welcome to IRC" % self.nickname)
    self.reply("002 %s :Your host is %s, running version miniircd-%s"
    % (self.nickname, server.name, VERSION))
    self.reply("003 %s :This server was created sometime"
    % self.nickname)
    self.reply("004 %s %s miniircd-%s o o"
    % (self.nickname, server.name, VERSION))
    self.send_lusers()
    self.send_motd()
    self.__handle_command = self.__command_handler

    def __send_names(self, arguments, for_join=False):
    server = self.server
    valid_channel_re = self.__valid_channelname_regexp
    if len(arguments) > 0:
    channelnames = arguments[0].split(",")
    else:
    channelnames = sorted(self.channels.keys())
    if len(arguments) > 1:
    keys = arguments[1].split(",")
    else:
    keys = []
    keys.extend((len(channelnames) - len(keys)) * [None])
    for (i, channelname) in enumerate(channelnames):
    if for_join and irc_lower(channelname) in self.channels:
    continue
    if not valid_channel_re.match(channelname):
    self.reply_403(channelname)
    continue
    channel = server.get_channel(channelname)
    if channel.key is not None and channel.key != keys[i]:
    self.reply(
    "475 %s %s :Cannot join channel (+k) - bad key"
    % (self.nickname, channelname))
    continue

    if for_join:
    channel.add_member(self)
    self.channels[irc_lower(channelname)] = channel
    self.message_channel(channel, "JOIN", channelname, True)
    self.channel_log(channel, "joined", meta=True)
    if channel.topic:
    self.reply("332 %s %s :%s"
    % (self.nickname, channel.name, channel.topic))
    else:
    self.reply("331 %s %s :No topic is set"
    % (self.nickname, channel.name))
    names_prefix = "353 %s = %s :" % (self.nickname, channelname)
    names = ""
    # Max length: reply prefix ":server_name(space)" plus CRLF in
    # the end.
    names_max_len = 512 - (len(server.name) + 2 + 2)
    for name in sorted(x.nickname for x in channel.members):
    if not names:
    names = names_prefix + name
    # Using >= to include the space between "names" and "name".
    elif len(names) + len(name) >= names_max_len:
    self.reply(names)
    names = names_prefix + name
    else:
    names += " " + name
    if names:
    self.reply(names)
    self.reply("366 %s %s :End of NAMES list"
    % (self.nickname, channelname))

    def __command_handler(self, command, arguments):
    def away_handler():
    pass

    def ison_handler():
    if len(arguments) < 1:
    self.reply_461("ISON")
    return
    nicks = arguments
    online = [n for n in nicks if server.get_client(n)]
    self.reply("303 %s :%s" % (self.nickname, " ".join(online)))

    def join_handler():
    if len(arguments) < 1:
    self.reply_461("JOIN")
    return
    if arguments[0] == "0":
    for (channelname, channel) in self.channels.items():
    self.message_channel(channel, "PART", channelname, True)
    self.channel_log(channel, "left", meta=True)
    server.remove_member_from_channel(self, channelname)
    self.channels = {}
    return
    self.__send_names(arguments, for_join=True)

    def list_handler():
    if len(arguments) < 1:
    channels = server.channels.values()
    else:
    channels = []
    for channelname in arguments[0].split(","):
    if server.has_channel(channelname):
    channels.append(server.get_channel(channelname))

    sorted_channels = sorted(channels, key=lambda x: x.name)
    for channel in sorted_channels:
    self.reply("322 %s %s %d :%s"
    % (self.nickname, channel.name,
    len(channel.members), channel.topic))
    self.reply("323 %s :End of LIST" % self.nickname)

    def lusers_handler():
    self.send_lusers()

    def mode_handler():
    if len(arguments) < 1:
    self.reply_461("MODE")
    return
    targetname = arguments[0]
    if server.has_channel(targetname):
    channel = server.get_channel(targetname)
    if len(arguments) < 2:
    if channel.key:
    modes = "+k"
    if irc_lower(channel.name) in self.channels:
    modes += " %s" % channel.key
    else:
    modes = "+"
    self.reply("324 %s %s %s"
    % (self.nickname, targetname, modes))
    return
    flag = arguments[1]
    if flag == "+k":
    if len(arguments) < 3:
    self.reply_461("MODE")
    return
    key = arguments[2]
    if irc_lower(channel.name) in self.channels:
    channel.key = key
    self.message_channel(
    channel, "MODE", "%s +k %s" % (channel.name, key),
    True)
    self.channel_log(
    channel, "set channel key to %s" % key, meta=True)
    else:
    self.reply("442 %s :You're not on that channel"
    % targetname)
    elif flag == "-k":
    if irc_lower(channel.name) in self.channels:
    channel.key = None
    self.message_channel(
    channel, "MODE", "%s -k" % channel.name,
    True)
    self.channel_log(
    channel, "removed channel key", meta=True)
    else:
    self.reply("442 %s :You're not on that channel"
    % targetname)
    else:
    self.reply("472 %s %s :Unknown MODE flag"
    % (self.nickname, flag))
    elif targetname == self.nickname:
    if len(arguments) == 1:
    self.reply("221 %s +" % self.nickname)
    else:
    self.reply("501 %s :Unknown MODE flag" % self.nickname)
    else:
    self.reply_403(targetname)

    def motd_handler():
    self.send_motd()

    def names_handler():
    self.__send_names(arguments)

    def nick_handler():
    if len(arguments) < 1:
    self.reply("431 :No nickname given")
    return
    newnick = arguments[0]
    client = server.get_client(newnick)
    if newnick == self.nickname:
    pass
    elif client and client is not self:
    self.reply("433 %s %s :Nickname is already in use"
    % (self.nickname, newnick))
    elif not self.__valid_nickname_regexp.match(newnick):
    self.reply("432 %s %s :Erroneous Nickname"
    % (self.nickname, newnick))
    else:
    for x in self.channels.values():
    self.channel_log(
    x, "changed nickname to %s" % newnick, meta=True)
    oldnickname = self.nickname
    self.nickname = newnick
    server.client_changed_nickname(self, oldnickname)
    self.message_related(
    ":%s!%s@%s NICK %s"
    % (oldnickname, self.user, self.host, self.nickname),
    True)

    def notice_and_privmsg_handler():
    if len(arguments) == 0:
    self.reply("411 %s :No recipient given (%s)"
    % (self.nickname, command))
    return
    if len(arguments) == 1:
    self.reply("412 %s :No text to send" % self.nickname)
    return
    targetname = arguments[0]
    message = arguments[1]
    client = server.get_client(targetname)
    if client:
    client.message(":%s %s %s :%s"
    % (self.prefix, command, targetname, message))
    elif server.has_channel(targetname):
    channel = server.get_channel(targetname)
    self.message_channel(
    channel, command, "%s :%s" % (channel.name, message))
    self.channel_log(channel, message)
    else:
    self.reply("401 %s %s :No such nick/channel"
    % (self.nickname, targetname))

    def part_handler():
    if len(arguments) < 1:
    self.reply_461("PART")
    return
    if len(arguments) > 1:
    partmsg = arguments[1]
    else:
    partmsg = self.nickname
    for channelname in arguments[0].split(","):
    if not valid_channel_re.match(channelname):
    self.reply_403(channelname)
    elif not irc_lower(channelname) in self.channels:
    self.reply("442 %s %s :You're not on that channel"
    % (self.nickname, channelname))
    else:
    channel = self.channels[irc_lower(channelname)]
    self.message_channel(
    channel, "PART", "%s :%s" % (channelname, partmsg),
    True)
    self.channel_log(channel, "left (%s)" % partmsg, meta=True)
    del self.channels[irc_lower(channelname)]
    server.remove_member_from_channel(self, channelname)

    def ping_handler():
    if len(arguments) < 1:
    self.reply("409 %s :No origin specified" % self.nickname)
    return
    self.reply("PONG %s :%s" % (server.name, arguments[0]))

    def pong_handler():
    pass

    def quit_handler():
    if len(arguments) < 1:
    quitmsg = self.nickname
    else:
    quitmsg = arguments[0]
    self.disconnect(quitmsg)

    def topic_handler():
    if len(arguments) < 1:
    self.reply_461("TOPIC")
    return
    channelname = arguments[0]
    channel = self.channels.get(irc_lower(channelname))
    if channel:
    if len(arguments) > 1:
    newtopic = arguments[1]
    channel.topic = newtopic
    self.message_channel(
    channel, "TOPIC", "%s :%s" % (channelname, newtopic),
    True)
    self.channel_log(
    channel, "set topic to %r" % newtopic, meta=True)
    else:
    if channel.topic:
    self.reply("332 %s %s :%s"
    % (self.nickname, channel.name,
    channel.topic))
    else:
    self.reply("331 %s %s :No topic is set"
    % (self.nickname, channel.name))
    else:
    self.reply("442 %s :You're not on that channel" % channelname)

    def wallops_handler():
    if len(arguments) < 1:
    self.reply_461("WALLOPS")
    return
    message = arguments[0]
    for client in server.clients.values():
    client.message(":%s NOTICE %s :Global notice: %s"
    % (self.prefix, client.nickname, message))

    def who_handler():
    if len(arguments) < 1:
    return
    targetname = arguments[0]
    if server.has_channel(targetname):
    channel = server.get_channel(targetname)
    for member in channel.members:
    self.reply("352 %s %s %s %s %s %s H :0 %s"
    % (self.nickname, targetname, member.user,
    member.host, server.name, member.nickname,
    member.realname))
    self.reply("315 %s %s :End of WHO list"
    % (self.nickname, targetname))

    def whois_handler():
    if len(arguments) < 1:
    return
    username = arguments[0]
    user = server.get_client(username)
    if user:
    self.reply("311 %s %s %s %s * :%s"
    % (self.nickname, user.nickname, user.user,
    user.host, user.realname))
    self.reply("312 %s %s %s :%s"
    % (self.nickname, user.nickname, server.name,
    server.name))
    self.reply("319 %s %s :%s"
    % (self.nickname, user.nickname,
    " ".join(user.channels)))
    self.reply("318 %s %s :End of WHOIS list"
    % (self.nickname, user.nickname))
    else:
    self.reply("401 %s %s :No such nick"
    % (self.nickname, username))

    handler_table = {
    "AWAY": away_handler,
    "ISON": ison_handler,
    "JOIN": join_handler,
    "LIST": list_handler,
    "LUSERS": lusers_handler,
    "MODE": mode_handler,
    "MOTD": motd_handler,
    "NAMES": names_handler,
    "NICK": nick_handler,
    "NOTICE": notice_and_privmsg_handler,
    "PART": part_handler,
    "PING": ping_handler,
    "PONG": pong_handler,
    "PRIVMSG": notice_and_privmsg_handler,
    "QUIT": quit_handler,
    "TOPIC": topic_handler,
    "WALLOPS": wallops_handler,
    "WHO": who_handler,
    "WHOIS": whois_handler,
    }
    server = self.server
    valid_channel_re = self.__valid_channelname_regexp
    try:
    handler_table[command]()
    except KeyError:
    self.reply("421 %s %s :Unknown command" % (self.nickname, command))

    def socket_readable_notification(self):
    try:
    data = self.socket.recv(2 ** 10)
    self.server.print_debug(
    "[%s:%d] -> %r" % (self.host, self.port, data))
    quitmsg = "EOT"
    except socket.error as x:
    data = ""
    quitmsg = x
    if data:
    self.__readbuffer += socket_to_buffer(data)
    self.__parse_read_buffer()
    self.__timestamp = time.time()
    self.__sent_ping = False
    else:
    self.disconnect(quitmsg)

    def socket_writable_notification(self):
    try:
    sent = self.socket.send(buffer_to_socket(self.__writebuffer))
    self.server.print_debug(
    "[%s:%d] <- %r" % (
    self.host, self.port, self.__writebuffer[:sent]))
    self.__writebuffer = self.__writebuffer[sent:]
    except socket.error as x:
    self.disconnect(x)

    def disconnect(self, quitmsg):
    self.message("ERROR :%s" % quitmsg)
    self.server.print_info(
    "Disconnected connection from %s:%s (%s)." % (
    self.host, self.port, quitmsg))
    self.socket.close()
    self.server.remove_client(self, quitmsg)

    def message(self, msg):
    self.__writebuffer += msg + "\r\n"

    def reply(self, msg):
    self.message(":%s %s" % (self.server.name, msg))

    def reply_403(self, channel):
    self.reply("403 %s %s :No such channel" % (self.nickname, channel))

    def reply_461(self, command):
    nickname = self.nickname or "*"
    self.reply("461 %s %s :Not enough parameters" % (nickname, command))

    def message_channel(self, channel, command, message, include_self=False):
    line = ":%s %s %s" % (self.prefix, command, message)
    for client in channel.members:
    if client != self or include_self:
    client.message(line)

    def channel_log(self, channel, message, meta=False):
    if not self.server.channel_log_dir:
    return
    if meta:
    format = "[%s] * %s %s\n"
    else:
    format = "[%s] <%s> %s\n"
    timestamp = datetime.utcnow().strftime("%Y-%m-%d %H:%M:%S UTC")
    logname = channel.name.replace("_", "__").replace("/", "_")
    fp = open("%s/%s.log" % (self.server.channel_log_dir, logname), "a")
    fp.write(format % (timestamp, self.nickname, message))
    fp.close()

    def message_related(self, msg, include_self=False):
    clients = set()
    if include_self:
    clients.add(self)
    for channel in self.channels.values():
    clients |= channel.members
    if not include_self:
    clients.discard(self)
    for client in clients:
    client.message(msg)

    def send_lusers(self):
    self.reply("251 %s :There are %d users and 0 services on 1 server"
    % (self.nickname, len(self.server.clients)))

    def send_motd(self):
    server = self.server
    motdlines = server.get_motd_lines()
    if motdlines:
    self.reply("375 %s :- %s Message of the day -"
    % (self.nickname, server.name))
    for line in motdlines:
    self.reply("372 %s :- %s" % (self.nickname, line.rstrip()))
    self.reply("376 %s :End of /MOTD command" % self.nickname)
    else:
    self.reply("422 %s :MOTD File is missing" % self.nickname)


    class Server(object):
    def __init__(self, options):
    self.ports = options.ports
    self.password = options.password
    self.ssl_pem_file = options.ssl_pem_file
    self.motdfile = options.motd
    self.verbose = options.verbose
    self.debug = options.debug
    self.channel_log_dir = options.channel_log_dir
    self.chroot = options.chroot
    self.setuid = options.setuid
    self.state_dir = options.state_dir
    self.log_file = options.log_file
    self.log_max_bytes = options.log_max_size * 1024 * 1024
    self.log_count = options.log_count
    self.logger = None

    if options.password_file:
    with open(options.password_file, "r") as fp:
    self.password = fp.read().strip("\n")

    if self.ssl_pem_file:
    self.ssl = __import__("ssl")

    # Find certificate after daemonization if path is relative:
    if self.ssl_pem_file and os.path.exists(self.ssl_pem_file):
    self.ssl_pem_file = os.path.abspath(self.ssl_pem_file)
    # else: might exist in the chroot jail, so just continue

    if options.listen:
    self.address = socket.gethostbyname(options.listen)
    else:
    self.address = ""
    server_name_limit = 63 # From the RFC.
    self.name = socket.getfqdn(self.address)[:server_name_limit]

    self.channels = {} # irc_lower(Channel name) --> Channel instance.
    self.clients = {} # Socket --> Client instance.
    self.nicknames = {} # irc_lower(Nickname) --> Client instance.
    if self.channel_log_dir:
    create_directory(self.channel_log_dir)
    if self.state_dir:
    create_directory(self.state_dir)

    def make_pid_file(self, filename):
    try:
    fd = os.open(filename, os.O_RDWR | os.O_CREAT | os.O_EXCL, 0o644)
    os.write(fd, "%i\n" % os.getpid())
    os.close(fd)
    except:
    self.print_error("Could not create PID file %r" % filename)
    sys.exit(1)

    def daemonize(self):
    try:
    pid = os.fork()
    if pid > 0:
    sys.exit(0)
    except OSError:
    sys.exit(1)
    os.setsid()
    try:
    pid = os.fork()
    if pid > 0:
    self.print_info("PID: %d" % pid)
    sys.exit(0)
    except OSError:
    sys.exit(1)
    os.chdir("/")
    os.umask(0)
    dev_null = open("/dev/null", "r+")
    os.dup2(dev_null.fileno(), sys.stdout.fileno())
    os.dup2(dev_null.fileno(), sys.stderr.fileno())
    os.dup2(dev_null.fileno(), sys.stdin.fileno())

    def get_client(self, nickname):
    return self.nicknames.get(irc_lower(nickname))

    def has_channel(self, name):
    return irc_lower(name) in self.channels

    def get_channel(self, channelname):
    if irc_lower(channelname) in self.channels:
    channel = self.channels[irc_lower(channelname)]
    else:
    channel = Channel(self, channelname)
    self.channels[irc_lower(channelname)] = channel
    return channel

    def get_motd_lines(self):
    if self.motdfile:
    try:
    return open(self.motdfile).readlines()
    except IOError:
    return ["Could not read MOTD file %r." % self.motdfile]
    else:
    return []

    def print_info(self, msg):
    if self.verbose:
    print(msg)
    sys.stdout.flush()
    if self.logger:
    self.logger.info(msg)

    def print_debug(self, msg):
    if self.debug:
    print(msg)
    sys.stdout.flush()
    if self.logger:
    self.logger.debug(msg)

    def print_error(self, msg):
    sys.stderr.write("%s\n" % msg)
    if self.logger:
    self.logger.error(msg)

    def client_changed_nickname(self, client, oldnickname):
    if oldnickname:
    del self.nicknames[irc_lower(oldnickname)]
    self.nicknames[irc_lower(client.nickname)] = client

    def remove_member_from_channel(self, client, channelname):
    if irc_lower(channelname) in self.channels:
    channel = self.channels[irc_lower(channelname)]
    channel.remove_client(client)

    def remove_client(self, client, quitmsg):
    client.message_related(":%s QUIT :%s" % (client.prefix, quitmsg))
    for x in client.channels.values():
    client.channel_log(x, "quit (%s)" % quitmsg, meta=True)
    x.remove_client(client)
    if client.nickname \
    and irc_lower(client.nickname) in self.nicknames:
    del self.nicknames[irc_lower(client.nickname)]
    del self.clients[client.socket]

    def remove_channel(self, channel):
    del self.channels[irc_lower(channel.name)]

    def start(self):
    serversockets = []
    for port in self.ports:
    s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
    try:
    s.bind((self.address, port))
    except socket.error as e:
    self.print_error("Could not bind port %s: %s." % (port, e))
    sys.exit(1)
    s.listen(5)
    serversockets.append(s)
    del s
    self.print_info("Listening on port %d." % port)
    if self.chroot:
    os.chdir(self.chroot)
    os.chroot(self.chroot)
    self.print_info("Changed root directory to %s" % self.chroot)
    if self.setuid:
    os.setgid(self.setuid[1])
    os.setuid(self.setuid[0])
    self.print_info("Setting uid:gid to %s:%s"
    % (self.setuid[0], self.setuid[1]))

    self.init_logging()
    try:
    self.run(serversockets)
    except:
    if self.logger:
    self.logger.exception("Fatal exception")
    raise

    def init_logging(self):
    if not self.log_file:
    return

    log_level = logging.INFO
    if self.debug:
    log_level = logging.DEBUG
    self.logger = logging.getLogger("miniircd")
    formatter = logging.Formatter(
    ("%(asctime)s - %(name)s[%(process)d] - "
    "%(levelname)s - %(message)s"))
    fh = RotatingFileHandler(
    self.log_file,
    maxBytes=self.log_max_bytes,
    backupCount=self.log_count)
    fh.setLevel(log_level)
    fh.setFormatter(formatter)
    self.logger.setLevel(log_level)
    self.logger.addHandler(fh)

    def run(self, serversockets):
    last_aliveness_check = time.time()
    while True:
    (iwtd, owtd, ewtd) = select.select(
    serversockets + [x.socket for x in self.clients.values()],
    [x.socket for x in self.clients.values()
    if x.write_queue_size() > 0],
    [],
    10)
    for x in iwtd:
    if x in self.clients:
    self.clients[x].socket_readable_notification()
    else:
    (conn, addr) = x.accept()
    if self.ssl_pem_file:
    try:
    conn = self.ssl.wrap_socket(
    conn,
    server_side=True,
    certfile=self.ssl_pem_file,
    keyfile=self.ssl_pem_file)
    except Exception as e:
    self.print_error(
    "SSL error for connection from %s:%s: %s" % (
    addr[0], addr[1], e))
    continue
    try:
    self.clients[conn] = Client(self, conn)
    self.print_info("Accepted connection from %s:%s." % (
    addr[0], addr[1]))
    except socket.error as e:
    try:
    conn.close()
    except:
    pass
    for x in owtd:
    if x in self.clients: # client may have been disconnected
    self.clients[x].socket_writable_notification()
    now = time.time()
    if last_aliveness_check + 10 < now:
    for client in list(self.clients.values()):
    client.check_aliveness()
    last_aliveness_check = now


    _maketrans = str.maketrans if PY3 else string.maketrans
    _ircstring_translation = _maketrans(
    string.ascii_lowercase.upper() + "[]\\^",
    string.ascii_lowercase + "{}|~")


    def irc_lower(s):
    return s.translate(_ircstring_translation)


    def main(argv):
    op = OptionParser(
    version=VERSION,
    description="miniircd is a small and limited IRC server.")
    op.add_option(
    "--channel-log-dir",
    metavar="X",
    help="store channel log in directory X")
    op.add_option(
    "-d", "--daemon",
    action="store_true",
    help="fork and become a daemon")
    op.add_option(
    "--debug",
    action="store_true",
    help="print debug messages to stdout")
    op.add_option(
    "--listen",
    metavar="X",
    help="listen on specific IP address X")
    op.add_option(
    "--log-count",
    metavar="X", default=10, type="int",
    help="keep X log files; default: %default")
    op.add_option(
    "--log-file",
    metavar="X",
    help="store log in file X")
    op.add_option(
    "--log-max-size",
    metavar="X", default=10, type="int",
    help="set maximum log file size to X MiB; default: %default MiB")
    op.add_option(
    "--motd",
    metavar="X",
    help="display file X as message of the day")
    op.add_option(
    "--pid-file",
    metavar="X",
    help="write PID to file X")
    op.add_option(
    "-p", "--password",
    metavar="X",
    help="require connection password X; default: no password")
    op.add_option(
    "--password-file",
    metavar="X",
    help=("require connection password stored in file X;"
    " default: no password"))
    op.add_option(
    "--ports",
    metavar="X",
    help="listen to ports X (a list separated by comma or whitespace);"
    " default: 6667 or 6697 if SSL is enabled")
    op.add_option(
    "-s", "--ssl-pem-file",
    metavar="FILE",
    help="enable SSL and use FILE as the .pem certificate+key")
    op.add_option(
    "--state-dir",
    metavar="X",
    help="save persistent channel state (topic, key) in directory X")
    op.add_option(
    "--verbose",
    action="store_true",
    help="be verbose (print some progress messages to stdout)")
    if os.name == "posix":
    op.add_option(
    "--chroot",
    metavar="X",
    help="change filesystem root to directory X after startup"
    " (requires root)")
    op.add_option(
    "--setuid",
    metavar="U[:G]",
    help="change process user (and optionally group) after startup"
    " (requires root)")
    else:
    op.chroot = False
    op.setuid = False

    (options, args) = op.parse_args(argv[1:])
    if options.debug:
    options.verbose = True
    if options.ports is None:
    if options.ssl_pem_file is None:
    options.ports = "6667"
    else:
    options.ports = "6697"
    if options.chroot:
    if os.getuid() != 0:
    op.error("Must be root to use --chroot")
    if options.setuid:
    from pwd import getpwnam
    from grp import getgrnam
    if os.getuid() != 0:
    op.error("Must be root to use --setuid")
    matches = options.setuid.split(":")
    if len(matches) == 2:
    options.setuid = (getpwnam(matches[0]).pw_uid,
    getgrnam(matches[1]).gr_gid)
    elif len(matches) == 1:
    options.setuid = (getpwnam(matches[0]).pw_uid,
    getpwnam(matches[0]).pw_gid)
    else:
    op.error("Specify a user, or user and group separated by a colon,"
    " e.g. --setuid daemon, --setuid nobody:nobody")
    if (os.getuid() == 0 or os.getgid() == 0) and not options.setuid:
    op.error("Running this service as root is not recommended. Use the"
    " --setuid option to switch to an unprivileged account after"
    " startup. If you really intend to run as root, use"
    " \"--setuid root\".")

    ports = []
    for port in re.split(r"[,\s]+", options.ports):
    try:
    ports.append(int(port))
    except ValueError:
    op.error("bad port: %r" % port)
    options.ports = ports
    server = Server(options)
    if options.daemon:
    server.daemonize()
    if options.pid_file:
    server.make_pid_file(options.pid_file)
    try:
    server.start()
    except KeyboardInterrupt:
    server.print_error("Interrupted.")


    main(sys.argv)

    #################################

    top of the script don't think needed just in case
    ya might add 'import ssl'
    on github the python file is named a bit different
    to start the script save it as example: minircd.py
    chmod +x the script

    as root from hidircz directory with your pem file and motd file:
    # python minircd.py --ssl-pem-file=/root/hidircz/hidz.pem --listen 127.0.0.1 --motd=huh.motd --setuid=root

    i didn't test this out but to run the script as non root ya might need change directory to say /home/nonrootuser
    move everything there, chown -R nonroot:nonroot all the files
    so ssl doesn't gripe about an error i might be wrong on this fyi

    to get help with the irc server:
    # python minircd.py -h

    i forgot to mention to start tor at least on arch:
    # /usr/bin/tor -f /etc/tor/torrc

    so now you have a irc tor chat server up in stealth mode
    plus an additional layer of ssl

    the clients say via irssi can connect as follows:
    # socat TCP4-LISTEN:8000,reuseaddr,fork SOCKS4a:127.0.0.1:newtorsitenamehere.onion:6697,socksport=9050

    you don't add the 'irc' in front of the 'domain' just the onion address without 'irc'

    then launch irssi and to connect
    /connect -ssl 127.0.0.1 8000

    you can create a room join chat typical irc stuff
    anything done as /whois will show localhost no ip info

    for pidgin users little different but not much...
    basic tab is irc protocol
    yer user name
    server is the tor address without 'irc'
    advanced tab
    port 6697
    proxy tab...
    proxy is http
    host 127.0.0.1 port 8118

    start privoxy before connecting:
    # /usr/bin/privoxy --no-daemon /etc/privoxy/config

    here is my privoxy config:
    #######################################

    # Generally, this file goes in /etc/privoxy/config
    # unfucked config by cm0s 010117
    # to start /usr/bin/privoxy --no-dameon /etc/privoxy/config
    # Tor listens as a SOCKS4a proxy here:
    forward-socks5 / 127.0.0.1:9050 .

    # confz
    confdir /etc/privoxy
    logdir /var/log/privoxy
    # actionsfile standard # Internal purpose, recommended
    actionsfile default.action # Main actions file
    actionsfile user.action # User customizations
    filterfile default.filter

    # timeout shit
    keep-alive-timeout 600
    # mohr timeout shit
    default-server-timeout 600
    # yet mohhhrrr...
    socket-timeout 600

    # Don't log interesting things, only startup messages, warnings and errors
    logfile logfile
    #jarfile jarfile
    #debug 0 # show each GET/POST/CONNECT request
    debug 4096 # Startup banner and warnings
    debug 8192 # Errors - *we highly recommended enabling this*

    user-manual /usr/share/doc/privoxy/user-manual
    listen-address localhost:8118
    toggle 1
    enable-remote-toggle 0
    enable-edit-actions 0
    enable-remote-http-toggle 0
    buffer-limit 4096
    #
    #
    ########################################

    a quick side note:
    make sure logging is off in pidgin and also the otr plugin

    so recap, ya just launched your very own irc chat server
    can make your own motd, publish your otr key add whatever custom
    stuff ya want and ya really made it private coz it's in stealth mode
    stealth mode tor is NOT listed in the tor directory and even if someone
    finds your onion address they can't do anything, won't even let them
    scan your address without the auth cookie, and you added another layer of ssl

    cheerz

    splif


  9. the thing about the 'vpn review' stuff and this includes myself from my own review, is everyone uses

    things different, what i mean by that is the individual's config

    until someone shows their whole box's config and how they actually route things, have their local set up

    all the way down to the OS and what else it is doing well point is a 'review' is really 'relative'

     

    the way i use 'arch linux' can be completely different than the way someone else uses it

    someone else might have a better config than me, better 'habits' maybe even read a manual

     

    k, done gripen


  10. here's my .rtorrent.rc config file

     

    # This is an example resource file for rTorrent. Copy to
    # ~/.rtorrent.rc and enable/modify the options as needed. Remember to
    # uncomment the options you wish to enable.
    
    # Maximum and minimum number of peers to connect to per torrent.
    min_peers = 50
    max_peers = 80
    
    # Same as above but for seeding completed torrents (-1 = same as downloading)
    min_peers_seed = 1
    max_peers_seed = 50
    
    # Maximum number of uploads single torrent may use
    max_uploads = 4
    
    # Maximum number of simultaneous downloads
    max_downloads_global = 10
    # Maximum number of simultaneous uploads
    max_uploads_global = 20
    
    # Global upload and download rate in KiB. "0" for unlimited.
    download_rate = 0
    upload_rate = 50
    
    # Default directory to save the downloaded torrents.
    directory = ~/d0wnz
    
    # Default session directory. Make sure you don't run multiple instance
    # of rtorrent using the same session directory. Perhaps using a
    # relative path?
    session = ~/d0wnz
    
    # Watch a directory for new torrents, and stop those that have been
    # deleted.
    schedule = watch_directory,5,5,load_start=./rtactive/*.torrent
    schedule = tied_directory,6,5,start_tied=
    schedule = untied_directory,7,5,stop_untied=
    
    # Close torrents when diskspace is low.
    schedule = low_diskspace,5,60,close_low_diskspace=2000M
    
    # Periodically save session data
    #schedule = session_save,240,300,session_save=
    
    # Enable the default ratio group.
    ratio.enable=
    # Change the limits, the defaults should be sufficient.
    # Upload to a minimum ratio of 4.0
    ratio.min.set=400
    # Upload to a maximum ratio of 20.0
    ratio.max.set=2000
    # Upload a minimum of 250 MB
    ratio.upload.set=250M
    
    # When seeding ratio is reached close the torrent
    system.method.set = group.seeding.ratio.command, d.close=
    
    # Move files to ./unsorted when download completes
    system.method.set_key = event.download.finished,move_complete,"d.set_directory=~/d0wnz/;execute=mv,-n,$d.get_base_path=,~/d0wnz/"
    
    # Port range to use for listening.
    port_range = 60125-64125
    
    # Start opening ports at a random position within the port range.
    port_random = yes
    
    # fixed diskspace properly reported...
    check_hash = yes
    
    # Encryption options, set to none (default) or any combination of the following:
    # allow_incoming, try_outgoing, require, require_RC4, enable_retry, prefer_plaintext
    #
    # The example value allows incoming encrypted connections, starts unencrypted
    # outgoing connections but retries with encryption if they fail, preferring
    # plaintext to RC4 encryption after the encrypted handshake
    #
    encryption = allow_incoming,try_outgoing,enable_retry
    
    # Sort the main view by ratio
    view.sort_current = main,greater=d.get_ratio=
    view.sort_new = main,less=d.get_ratio=
    view.sort = main
    
    # Sort the seeding view by the upload rate and only show torrents with peers
    view.sort_current = seeding,greater=d.get_up_rate=
    view.filter = seeding,"and=d.get_complete=,d.get_peers_connected="
    view.sort_new = seeding,less=d.get_up_rate=
    view.sort = seeding
    
    # Sort the leeching view by name
    view.sort_current = leeching,greater=d.get_name=
    view.sort_new = leeching,greater=d.get_name=
    view.sort = leeching
    
    # Filter the active view by connected peers
    view.sort_current = active,less=d.get_name=
    view.sort_new = leeching,less=d.get_name=
    view.filter = active,d.get_peers_connected=
    view.sort = active
    
    schedule = sort_main,11,5,view.sort=main
    schedule = sort_seeding,12,5,view.sort=seeding
    schedule = sort_leeching,13,5,view.sort=leeching
    schedule = sort_active,14,5,view.sort=active
    
    # Enable DHT support for trackerless torrents or when all trackers are down.
    # May be set to "disable" (completely disable DHT), "off" (do not start DHT),
    # "auto" (start and stop DHT as needed), or "on" (start DHT immediately).
    # The default is "off". For DHT to work, a session directory must be defined.
    # 
    dht = auto
    
    # UDP port to use for DHT.
    #
    dht_port = 63425
    
    # Enable peer exchange (for torrents not marked private)
    #
    peer_exchange = yes
    
    

  11. updated a global dark to dim the lights here got rid of the old green one i had modded

    shame on userstyles dot org messing their site up so bad

    glad i got the ones i liked from there and just mod them

    062617: updated the css go full screen forum width

    5951cc8faaf07.png

    /*
    about:config
    search stylish set
    editor to 1
    took global dark modded it
    edit_062617
    */
    
    @namespace url(http://www.w3.org/1999/xhtml);
    
    @-moz-document domain(airvpn.org) {
    
    @-moz-document url-prefix("about:preferences"),url-prefix("about:addons"){
        * { color: #999 !important; background-color: #2C2E2F !important; }
    #categories *    {color:#6C7075 }
    #categories,
    #nav-header    {background:#2C2E2F !important;color:#E0E0E0 !important;}
    .main-content     {background:#2C2E2F !important}
        .addon-view[notification], .addon-view[pending] { background-image:none !important; color:#FFF !important;background:#4D679A!important}
    #categories [selected="true"],
    #categories richlistitem:hover    {color:#E0E0E0 !important;background:#4D679A!important}}
    
    
    /*----- SITES TO EXCLUDE -----*/
    @-moz-document regexp("https?://(?!(www.your.sites.here.com|www.rememberthemilk.com|youtube.com|facebook.com|keep.google.com|calendar.google.com|mail.google.com|forum.example.com)).*"), url-prefix(ftp://), url-prefix(file://), url-prefix(javascript),url-prefix(about:),regexp("!about:preferences"),url-prefix("about:addons"),url-prefix("https://www.google.com") { html, #newtab-window {background: 
    
    
         /***** COPY AND PASTE THE URL OF YOUR BACKROUND-IMAGE INSIDE THE "": *****/
    
         
         /***** FOR A SIMPLE BLACK BACKGROUND JUST REMOVE THE URL LINE ABOVE *****/
         /***** Some background-images (you can also use your own url):
    
       default:     http://abload.de/img/b1fgs11.png
       old default: http://abload.de/img/ultra_x2vm9k.jpg
                    http://abload.de/img/b2w4shd.png
                    http://abload.de/img/b3qrs99.png
                    http://abload.de/img/b4zcse8.png
                    http://abload.de/img/b5b1s7x.png
                    http://abload.de/img/b6umsmy.png
                    http://abload.de/img/b7ars8c.png
                    http://abload.de/img/kubrickbgcolor2darkr8skc.png
                    http://abload.de/img/xpattern_darkq8s3i.png
                    http://abload.de/img/mainpatternolxcq.png
    
    */ #000000 /* fixed */ !important}
    
    
    /*----- DEFAULT TEXT, BORDER & BACKGROUND COLORS -----*/
    * {
        color: #999 !important;
        box-shadow: none !important;
        background-color: transparent !important;
        border-color: #000000 !important;
        border-top-color: #000000 !important;
        border-bottom-color: #000000 !important;
        border-left-color: #000000 !important;
        text-shadow: none !important;
        border-right-color: #000000 !important}
    body {background: transparent !important}
    *:before, *:after {background-color: transparent !important; border-color: #000000 !important}
    
    a, a * {
        color: #409B9B !important;
        text-decoration: none !important}
    a:hover, a:hover *, a:visited:hover, a:visited:hover *, span[onclick]:hover, div[onclick]:hover, [role="link"]:hover, [role="link"]:hover *, [role="button"]:hover *, [role="menuitem"]:hover, [role="menuitem"]:hover *, .link:hover, .link:hover * {
        color: #F0F0F0 !important;
        }
    a:visited, a:visited * {
        color: #607069 !important}
    a.highlight, a.highlight *, a.active, a.active *, .selected, .selected *, [href="#"] {
        color: #DDD !important;
        font-weight: bold !important}
    
    h1, h2, h3, h4, h5, h6, h1 *, h2 *, h3 *, strong, [id*="headline"], [class*="headline"], [id*="header"], [class*="header"], [class*="header"] td {
        color: #859900 !important}
    a h1, a h2, a h3, a h4, a h5, a h6, h1 a, h2 a, h3 a, a strong, a[id*="headline"], a[class*="headline"], a[id*="header"], a[class*="header"] {
        text-decoration: underline !important}
    [class*="error"], [class*="alert"], code, span[onclick], div[onclick] {
        color: #900 !important}
    
    ::-moz-selection {background: #377 !important; color: #000000 !important}
    ::selection {background: #377 !important; color: #000000 !important}
    :focus {outline: none !important}
    
    /*----- MENU & CO BACKGROUND-COLORS -----*/
    div[style="display: block;"], div[role="navigation"] {background: rgba(0,0,0,.5) !important}
    
    table {
        background: rgba(40,30,30,.6) !important;
        border-radius: 6px !important}
    table > tbody > tr:nth-child(even), table > tbody > tr > td:nth-child(even) {
        background-color: rgba(0,0,0,.2) !important}
    
    iframe, embed, header, nav, footer, label [onclick], nav ul, div[style*="position:"][style*="left:"][style*="visible"], div[style*="z-index:"][style*="left:"][style*="visible"], div[style*="-moz-user-select"], div[role="menu"], div[role="dialog"], span[class*="script"] div, [id*="menu"], [class*="dropdown"], [class*="popup"], [class="title"], ul[style*="display:"], ul[style*="visibility:"] ul, [id*="nav"] ul, [class*="nav"] ul, ul[class*="menu"], a[onclick][style*="display"], a[id*="ghosteryfirefox"], #ghostery-purple-bubble, #translator-popup, .menu, .tooltip, .hovercard, .vbmenu_popup {
        background: rgba(5,5,5,.9) !important;
        border-radius: 5px;
        }
    [id*="overlay"], [id*="lightbox"], blockquote {
        background-color: rgba(35,35,35,.9) !important;
        border-radius: 5px}
    pre, dl, .Message code {
        background-color: rgba(5,5,5,.5) !important}
    
    
    /*----- DEFAULT BUTTONS, SEARCHBOXES & CO -----*/
    input, select, button, [role="button"], a.button, a.submit, a.BigButton, a.TabLink, .install[onclick] {
        -moz-appearance: none !important;
        -webkit-appearance: none !important;
        transition: border-color 0.3s !important;
        background: #060606 !important;
        color: #BBB !important;
        border: 2px solid #000000 !important;
        border-radius: 4px !important;
        }
    a[href="javascript:;"], a[class*="button"]:not(:empty), a[id*="button"]:not(:empty), a[id*="Button"]:not(:empty), div[class*="button"][onclick] {
        transition: border-color 0.3s !important;
        background: #060606 !important;
        color: #BBB !important;
        border-color: #000000 !important;
        }
    a[href="javascript:;"]:hover, a[class*="button"]:not(:empty):hover, a[id*="button"]:hover, a[id*="Button"]:not(:empty):hover, div[class*="button"][onclick]:hover {
        background: #151515 !important;
        color: #FFF !important}
    input *, select *, button *, a.button *, a.submit * {
        color: #BBB !important;
        }
    input:hover, input[type="button"]:hover, input[type="checkbox"]:hover, input[type="radio"]:hover, select:hover, button:hover, [role="button"]:hover, a.button:hover, a.submit:hover, a.BigButton:hover, a.TabLink:hover {
        border: 2px solid #555 !important;
        border-top-color: #555 !important;
        border-bottom-color: #555 !important;
        border-left-color: #555 !important;
        border-right-color: #555 !important}
    input:focus, select:focus {
        }
    input *:hover * {
        color: #F0F0F0 !important;
        }
    input[type="checkbox"], input[type="checkbox"]:focus {
        border: 2px solid #000000 !important;
        background-color: #000000 !important;
        color: #DDD !important;
        border-radius: 4px !important}
    input[type="radio"], input[type="radio"]:focus {
        border: 2px solid #000000 !important;
        background-color: #000000 !important;
        color: #DDD !important}
    input[type="checkbox"], input[type="radio"] {min-width: 10px; min-height: 10px}
    
    select input[type="button"], select button {border: none !important}
    select button {min-height: 8px !important}
    
    button:active, input[type="submit"]:active, input[type="button"]:active, a.button:active, a[class*="button"]:not(:empty):active, a.submit:active, a.BigButton:active, a.TabLink:active, .Active .TabLink {
        background: #292929 !important;
        color: #FFF !important}
    
    textarea {
        -moz-appearance: none !important;
        -webkit-appearance: none !important;
        background: rgba(0,0,0,.3) !important;
        border-radius: 3px !important;
        border: 1px solid #000000 !important;
        transition: border-color, background, 0.3s !important}
    textarea, textarea * {
        color: #C8C8C8 !important;
        }
    textarea:hover, textarea:focus:hover {
        border-color: #000000 !important}
    textarea:focus {
        background: rgba(0,0,0,.5) !important;
        border-color: #000000 !important}
    textarea:focus, textarea:focus > * {
        box-shadow: none !important}
    
    option {
        -moz-appearance: none !important;
        -webkit-appearance: none !important;
        background: none !important;
        color: #666 !important}
    option:not([disabled]):hover, option:focus, option:checked {
        background: linear-gradient(#000000, #292929) !important;
        color: #DDD !important}
    
    /* webkit checkbox & select fix */
    @media screen and (-webkit-min-device-pixel-ratio:0) {
    input[type="checkbox"]:checked, input[type="radio"]:checked {border-color: #DDD !important}
    select {
        padding-right: 12px !important;
        background: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA8AAAAKCAYAAABrGwT5AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAApSURBVChTYxjiYObMmf+hTBSASxwDoCskWiMMwDSQrBEGyNY4FAADAwDdpBOHzViE2AAAAABJRU5ErkJggg==) #000000 no-repeat !important;
        background-position: right center !important} }
    
    /*----- SCROLLBAR CHANGES -----*/
    scrollbarbutton {
        -moz-appearance: none !important;
        background-color: transparent;
        border: none !important}
    thumb {
        -moz-appearance: none !important;
        border: 2px solid transparent !important;
        background: #999 !important;
        background-clip: padding-box !important;
        border-radius: 3px !important;
        }
    scrollbar {
        -moz-appearance: none !important;
        background: transparent !important;
        }
    scrollbarbutton:hover, thumb:active, thumb:hover {
        opacity: 0.5 !important}
    
    scrollbar[orient="vertical"] thumb {min-width: 12px !important; max-width: 12px !important; min-height: 14px !important}
    scrollbar[orient="horizontal"] thumb {min-height: 12px !important; max-height: 12px !important; min-width: 14px !important}
    scrollbar[orient="vertical"] {min-width: 12px !important; max-width: 12px !important}
    scrollbar[orient="horizontal"] {min-height: 12px !important; max-height: 12px !important}
    
    
    /*----- IMAGE CHANGES -----*/
    body, *:not(:empty):not(html):not(span):not(a):not(:not(option):not(img):not([style="display: block;"]):not([onclick*="open"]):not([onclick*="s_objectID"]):not([class*="stars"]):not([id*="stars"]):not([id="rating"]):not([class="rating"]):not([class*="SPRITE"]):not([id*="SPRITE"]):not([class*="item"]):not([id*="item"]):not([class*="thumb"]):not([class*="icon"]):not(.text):not([id*="lbImage"]):not([class*="cc-in"]):not([class*="gr-body"]):not([id*="watch"]):not(#globalsearch):not(.sp),
    .r3_hm, .gmbutton2 b, .gtab-i, .ph, .bstab-iLft, .csb, #pagination div, [style*="sprite2.png"], #mw-head-base, #mw-page-base {
        background-image: none !important}
    
    img {opacity: .7 !important; transition: opacity .2s}
    img:hover, a:hover img {opacity: 1 !important}
    
    }
    
    
    /*----- ABOUT PAGES BACKGROUND -----*/
    @-moz-document url-prefix(about) {
    #newtab-window, #addons-page {background: #151515 !important}
    * {background-color: transparent}
    body > * {background-color: rgba(0,0,0,.5) !important}
    #list-view {background: #000000 !important}
    #detail-view {background: #000000 !important}
    #addons-page > * > *, #addons-page > * > * > * {border-color: #000000 !important} }
    
    /*----- SHOW INSTALLS ON USERSTYLES.ORG -----*/
    @-moz-document domain(userstyles.org) {
    li[total-install-count]:after {
        font-size: .70em !important;
        content: " (Installs: " attr(total-install-count) ", " attr(weekly-install-count) " wk)"} }
    
    /*----- RIGHT-CLICK MENUS & TOOLTIP STYLE -----*/
    #contentAreaContextMenu menuitem[disabled="true"], 
    #contentAreaContextMenu menuitem[disabled="true"] menuseparator {
        display: none !important}
    
    menupopup, popup,
    popup > menu > menupopup,
    menupopup > menu > menupopup {
        -moz-appearance: none !important;
        background: rgba(15,15,15,.9) !important;
        border: 1px solid #000000 !important;
        border-radius: 3px !important;
        padding: 2px 0 !important}
    menupopup * {box-shadow: none !important; color: #777 !important}
    menupopup menuitem:hover * {
        color: #F0F0F0 !important;
        }
    menupopup menuseparator {
        -moz-appearance: none !important;
        background: transparent !important;
        margin: 2px 0 2px -3px !important;
        padding: 0 !important;
        border-top: none !important;
        border-color: transparent !important;
        }
    menupopup menuitem {
        -moz-appearance: none !important;
        background: transparent !important;
        }
    menupopup menuitem:hover, menuitem[_moz-menuactive="true"] {
        background: #000000 !important;
    }
    tooltip {
        -moz-appearance: none !important;
        color: #CCC !important;
        background: rgba(0,0,0,.8) !important;
        border: 1px solid #555 !important;
        border-radius: 3px !important}
    
    /*----- FIX WHITE NEW TAB FLASH -----*/
    browser[type="content-primary"] {background: #151515 !important}
    
    /****************** AIRVPN MODZ  *****************//////////
    
    #copyright {
      display: none;
    }
    
    #index_stats {
      display: none;
    }
    
    #footer_utilities {
      display: none;
    }
    
    div.ipsSideBlock:nth-child(1) > div:nth-child(2) {
       display: none;
    }
    
    div.ipsSideBlock:nth-child(2) > div:nth-child(2) {
       display: none;
    }
    
    .message.error {
        background-color: #F3E3E6;
        border-color: #E599AA;
        color: #80001C;
        display: none;
    }
    
    .category {
        display: block;
        margin: 30px;
        padding: 10px;
        box-shadow: 0px 0px 3px #808080;
        border-radius: 10px;
        background: #000000;
    }
    
    .air_nav1_item_sel {
        display: inline-block;
        display: block;
        float: left;
        height: 20px;
        background: #000000 !important;
        color: white;
        margin: 5px;
        margin-bottom: 0px;
        text-align: center;
        padding-top: 12px;
        padding-left: 9px;
        padding-right: 12px;
        padding-bottom: 3px;
        box-shadow: 3px 0px 3px #0753B8;
        -webkit-box-shadow: 3px 0px 3px #0753B8;
        -moz-box-shadow: 3px 0px 3px #0753B8;
        text-shadow: 1px 1px black;
        transition: background-color 0.2s;
    }
    
    img.bitcoinsign {
        visibility: hidden !important;
    }
    
    #branding {
        border: 0px none;
        background-color: #000000 !important;
        background-image: url("/img/gradient4.png") !important;
        background-repeat: repeat-x !important;
    }
    
    #primary_nav > li > a, #community_app_menu > li > a, #community_app_menu .submenu_container li > a {
        height: 16px;
        padding-top: 12px;
        padding-left: 10px;
        padding-right: 10px;
        color: #080 !important;
        background-color: #000000 !important;
    }
    
    pre.prettyprint, code.prettyprint {
        background-color: #000000 !important;
        border-radius: 4px;
        color: #000000;
        padding: 5px;
        border: 1px solid #C9C9C9;
        overflow: auto;
        margin-left: 10px;
        font-size: 13px;
        line-height: 140%;
        font-family: monospace !important;
    }
    
    table.cke_editor td {
        padding: 0px !important;
        background: #000000 !important;
    }
    
    .cke_skin_ips .cke_wrapper {
        padding: 0px 5px 0px 3px !important;
        border: 2px solid #000000 !important;
        background-color: #000000 !important;
        background-image: none !important;
    }
    
    pre.prettyprint {
        width: 95%;
        margin: 1em auto;
        padding: 1em;
        background: #000000 !important;
        color: #080 !important;
    }
    
    pre._prettyXprint {
        background-color: #000000 !important;
        border-radius: 4px;
        color: #080 !important;
        border: 1px solid #448AE7 !important;
        overflow: auto;
        font-size: 13px;
        line-height: 140%;
        width: 95%;
        margin: 1em auto;
        padding: 1em;
        white-space: pre-wrap;
        font-family: monospace !important;
    }
    
    .post_block .post_controls li a.ipsButton_secondary {
        opacity: 1;
        background: #000000 !important;
    }
    
    .ipsLikeButton.ipsLikeButton_enabled {
        background: #7B96BB url("https://airvpn.org/public/style_images/master/like_button.png") no-repeat scroll left top;
        border: 1px solid #7B96BB;
        background: #000000 !important;
        color: #080 !important;
    }
    
    .ipsButton_secondary {
        height: 22px;
        line-height: 22px;
        font-size: 12px;
        padding: 0px 10px;
        background: transparent -moz-linear-gradient(center top , #000000 0%, #000000 100%) repeat scroll 0% 0%;
        border: 1px solid #7B96BB;
        box-shadow: 0px 1px 0px #FFF inset, 0px 1px 0px rgba(0, 0, 0, 0.3);
        border-radius: 3px;
        color: #080 !important;
        display: inline-block;
        white-space: nowrap;
        transition: all 0.2s ease-in-out 0s;
    }
    
    .topic_buttons li.important a, .topic_buttons li.important span, .ipsButton .important, .topic_buttons li a, .topic_buttons li span, .ipsButton {
        font: 300 14px/1.3 "Proxima-Nova",Helvetica,Arial,sans-serif;
        height: auto;
        padding: 0.5em;
        background: #000000 !important;
        color: #080 !important;
    }
    
    .ipsLikeButton.ipsLikeButton_disabled {
        background: #000000 url("https://airvpn.org/public/style_images/master/like_button.png") no-repeat scroll left bottom;
        border: 1px solid #ACACAC;
        color: #080 !important;
        background: #000000 !important;
    }
    
    @media screen {
       .str, .kwd, .com, .typ, .lit { color: #448AE7 !important }
       .pun, .opn, .clo, .pln, .tag, .atn, .atv, .dec, .var, .fun { color: #448AE7 !important }
    
    }
    
    #ipboard_body > div:nth-child(7) {
       display: none !important;
    }
    
    #ipboard_body > div:nth-child(9) {
       display: none !important;
    }
    
    #ipboard_body > div:nth-child(11) {
       display: none !important;
    }
    
    #generic__okDialogue_popup {display:none;}
    
    .ipsLayout_largeright.ipsLayout_withright {
        padding-right: 0px;
    }
    .ipsLayout.ipsLayout_withright {
        padding-right: 0px;
        clear: left;
    }
    
    .ipsLayout_largeright.ipsLayout .ipsLayout_right {
        width: 270px;
        margin-right: -280px;
        display: none;
    }
    
    

  12. script put together today for those wanting a quick AP

    tested with iphone and 36nh wifi card

     

    i'm not a coder so mod it for your distro

    fixes/improvements etc

     

    airap.png

     

    #!/bin/bash
    # 062117
    # ap script for openvpn via ssl/443
    # mod for yer distro or vpn needs
    # i'm not a coder so double check for 
    # any errors/improvements etc.   
    # tested with iphone and alfa awus036nh
    ##################################################
    LG='\033[0;37m'
    LB='\033[1;34m' 
    LC='\033[1;36m'
    BO='\033[0;33m'
    YL='\033[1;33m'
    GR='\033[0;32m'
    RD='\033[0;31m'
    NC='\033[0m' # No Color
    ##################################################
    f_exit(){
    clear
    exit 2> /dev/null
    }
    ##################################################
    # ctrl+c
    trap f_stop 2
    ##################################################
    f_stop(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    # 
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}flushen the toilet bruh...${NC}\n"
    sleep 1
    # stop the mcluvnz 
    if [ ! -z "$(pidof dnsmasq)" ]; then kill $(pidof dnsmasq); fi
    if [ ! -z "$(pidof macchanger)" ]; then kill $(pidof macchanger); fi
    if [ ! -z "$(pidof xterm)" ]; then kill $(pidof xterm); fi
    if [ ! -z "$(pidof create_ap)" ]; then kill $(pidof create_ap); fi
    #
    echo "0" > /proc/sys/net/ipv4/ip_forward
    #
    # stop apz
    killall -9 create_ap > /dev/null 2>&1
    sleep 1
    f_mainmenu
    }
    ##################################################
    f_tblzvpn(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    # 
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}IPTABLEs VPN/SSL${NC}"
    sleep 4
    #
    iptables -F
    iptables -t nat -F
    iptables -t mangle -F
    #
    iptables -X
    iptables -t nat -X
    iptables -t mangle -X
    #
    iptables -P INPUT DROP
    iptables -P FORWARD DROP
    #
    iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT 
    iptables -A INPUT -p tcp -m state --state NEW -m multiport --dports 80,443 -j ACCEPT 
    #
    iptables -A INPUT -i lo -j ACCEPT
    iptables -A OUTPUT -o lo -j ACCEPT
    #
    iptables -A OUTPUT -d 255.255.255.255 -j ACCEPT 
    iptables -A INPUT -s 255.255.255.255 -j ACCEPT 
    iptables -A INPUT -s 192.168.0.0/16 -d 192.168.0.0/16 -j ACCEPT 
    iptables -A OUTPUT -s 192.168.0.0/16 -d 192.168.0.0/16 -j ACCEPT
    iptables -A FORWARD -i eth0 -o tun0 -j ACCEPT
    iptables -A FORWARD -i tun0 -o eth0 -j ACCEPT 
    iptables -t nat -A PREROUTING -s 0/0 -p udp --dport 53 -j DNAT --to 10.5.0.1 
    iptables -t nat -A PREROUTING -s 0/0 -p tcp --dport 53 -j DNAT --to 10.5.0.1 
    iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE 
    iptables -A OUTPUT -o eth0 ! -d 127.0.0.1 -p tcp --dport 1413 -j DROP 
    #
    # ignore bad error messages
    for f in /proc/sys/net/ipv4/icmp_ignore_bogus_error_responses;
    do
    echo 1 > $f
    done        
    #
    # Disable response to broadcasts 
    for f in /proc/sys/net/ipv4/icmp_echo_ignore_broadcasts;
    do
    echo 1 > $f
    done
    #
    # disable source routed packets
    for f in /proc/sys/net/ipv4/conf/*/accept_source_route; 
    do
    echo 0 > $f
    done
    #
    # enable TCP SYN cookie 
    for f in /proc/sys/net/ipv4/tcp_syncookies;
    do
    echo 1 > $f
    done
    #
    # disable ICMP redirect acceptance
    for f in /proc/sys/net/ipv4/conf/*/accept_redirects; 
    do
    echo 0 > $f
    done
    #
    # no redirect messages
    for f in /proc/sys/net/ipv4/conf/*/send_redirects; 
    do
    echo 0 > $f
    done
    #
    # drop spoofz 
    for f in /proc/sys/net/ipv4/conf/*/rp_filter; 
    do
    echo 1 > $f
    done
    #
    # save stuff
    if [ ! -e /root/tablz ]; then mkdir /root/tablz; fi
    iptables-save > /root/tablz/iptables.rules
    #
    f_mainmenu
    }
    ##################################################
    f_tblzallow(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    # 
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}IPTABLEs ALLOW ALL${NC}"
    sleep 4
    #
    iptables -F
    iptables -X
    iptables -P INPUT ACCEPT
    iptables -P OUTPUT ACCEPT
    #
    f_mainmenu
    }
    ##################################################
    f_install(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    # 
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}nstallen create_ap${NC}\n"
    sleep 2
    reqs1="create_ap"
    sleep 1
    pacman -S --noconfirm --needed $reqs1
    sleep 2
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}create_ap installed${NC}\n"
    sleep 4
    #
    f_mainmenu
    }
    ##################################################
    f_makaddy(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    #
    clear
    unset WIFACE
    while [ -z "${WIFACE}" ]; do 
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}name of wifi card such as wlan0: ${NC}\n")" WIFACE; done
    sleep 1
    #
    clear
    unset macvar
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}wanna change yer mac addy for AP? [y/N]: ${NC}\n")" macvar
    mac_answer=$(echo ${macvar} | tr '[:upper:]' '[:lower:]')
    #
    sleep 1
    clear
    unset random_mac
    unset ap_mac
    if [ "${mac_answer}" == "y" ]; then
    	while [ -z "${random_mac}" ]; do 
    	f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}random or manual? [r/m]: ${NC}\n")" random_mac; done
    	case ${random_mac} in
    		r|R) ip link set ${WIFACE} down && macchanger -r ${WIFACE} && ip link  set ${WIFACE} up;;
    	    m|M) while [ -z "${ap_mac}" ]; do 
            clear && f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}with caps enter macaddy for AP: ${NC}\n")" ap_mac; done
            if [ -z $(echo ${ap_mac} | sed -n "/^\([0-9A-Z][0-9A-Z]:\)\{5\}[0-9A-Z][0-9A-Z]$/p") ]; then
            clear && f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}nvalid macaddy bruh...${NC}\n"
    	    sleep 1
    	    f_makaddy
    	    else
    	    ip link set ${WIFACE} down
    	    sleep 1 
    	    macchanger -m ${ap_mac} ${WIFACE}
    	    sleep 1 
    	    iplink set ${WIFACE} up
    	    fi
    	esac
    fi
    }			 
    ##################################################
    f_airAP(){
    #
    virtcent=$((`tput lines`/2-5))
    horcent=$((`tput cols`/2-10))
    #
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}HIDDEN AP WPA2 STATIC DNS w/NET${NC}"
    sleep 4
    clear
    f_banz && tput cup $virtcent $horcent && echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}ctrl + c to stop the AP ${NC}"
    sleep 4
    #
    f_makaddy
    #
    clear
    unset DNSZ                  
    while [ -z "${DNSZ}" ]; do 
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}enter static dns such as 10.5.0.1: ${NC}\n")" DNSZ; done
    sleep 2
    #
    clear
    unset IFACE                  
    while [ -z "${IFACE}" ]; do 
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}iface connected to net such as eth0/tun0: ${NC}\n")" IFACE; done
    sleep 2
    #
    clear
    unset ESSID
    while [ -z "${ESSID}" ]; do 
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}enter name of AP: ${NC}\n")" ESSID; done
    sleep 2
    #
    clear
    unset PASZ
    while [ -z "${PASZ}" ]; do 
    f_banz && tput cup $virtcent $horcent && read -p "$(echo -e "\n\e[1;34m                                      [*]\e[0m ${GR}enter wpa2 password: ${NC}\n")" PASZ; done
    sleep 2
    create_ap -m nat --dhcp-dns ${DNSZ} ${WIFACE} ${IFACE} --hidden ${ESSID} ${PASZ} --no-virt
    sleep 2
    f_mainmenu
    }
    ##################################################
    # menu stuff
    ##################################################
    f_banz(){
    tput setaf 2
    echo -e ' 
    
    
                                           ____ _ ____ _  _ ___  _  _    ____ ___  
                                           |__| | |__/ |  | |__] |\ | __ |__| |__] 
                                           |  | | |  \  \/  |    | \|    |  | |    
                                                                                                            '
    
    
        
                                                                                                 
                                       
    tput setaf 7 
    echo -e '                                       =======================================                 '
    tput sgr0
    }
    ##################################################
    f_mainmenu(){
    clear
    f_banz
    echo -e "                                       ${LB}Main Menu\n"
    echo -e "                                       ${RD}1. ${BO}airAP${NC}"
    echo -e "                                       ${RD}2. ${BO}tablz VPN${NC}"
    echo -e "                                       ${RD}3. ${BO}tablz ALLOW${NC}"
    echo -e "                                       ${RD}4. ${BO}install${NC}"
    echo -e "                                       ${RD}5. ${BO}exit${NC}"
    echo
    echo
    read -p "                                       Choice: " mainmenuchoice
    
    case ${mainmenuchoice} in
    1) unset clean; f_airAP ;;
    2) unset clean; f_tblzvpn ;;
    3) unset clean; f_tblzallow ;;
    4) unset clean; f_install ;;
    5) f_exit ;;
    *) f_mainmenu ;;
    esac
    }
    ##################################################
    # root shit
    if [ "$(id -u)" != "0" ]; then
    echo -e "\n\e[1;34m                             [*]\e[0m ${GR}roll as root bruh...\n" 1>&2
    exit 1
    else
    clean=1
    f_mainmenu
    fi
    ##################################################
    
    

     


  13. not familiar with eddie but saw in your logs 'stunnel' for me that is on port 443

    also says 'openvpn driver not installed'

    that might be why the time out

    the operating system can not talk to the thingymajigger

    that has the widget on stand by thereby

    goofen the flux capacitor

     

    i think this might be the driver you need if not my bad

    https://openvpn.net/index.php/open-source/downloads.html

     

    these guys did this:

    https://airvpn.org/topic/13126-driver-installation-failed/

     

    https://airvpn.org/windows/

×
×
  • Create New...