aboutsummaryrefslogtreecommitdiffstats
path: root/lib/python2.7/site-packages/Twisted-12.2.0-py2.7-linux-x86_64.egg/twisted/tap/telnet.py
blob: bc0c8020be1f134fe84d78c734bd637f1cc1087b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# Copyright (c) Twisted Matrix Laboratories.
# See LICENSE for details.


"""
Support module for making a telnet server with twistd.
"""

from twisted.manhole import telnet
from twisted.python import usage
from twisted.application import strports

class Options(usage.Options):
    synopsis = "[options]"
    longdesc = "Makes a telnet server to a Python shell."
    optParameters = [
         ["username", "u", "admin","set the login username"],
         ["password", "w", "changeme","set the password"],
         ["port", "p", "4040", "port to listen on"],
    ]

    compData = usage.Completions(
        optActions={"username": usage.CompleteUsernames()}
        )

def makeService(config):
    t = telnet.ShellFactory()
    t.username, t.password = config['username'], config['password']
    s = strports.service(config['port'], t)
    t.setService(s)
    return s