mirror of
https://github.com/paradoxxxzero/butterfly.git
synced 2026-05-31 17:39:41 +00:00
Fix INET6 sockets
This commit is contained in:
4
.gitmodules
vendored
4
.gitmodules
vendored
@@ -1,3 +1,3 @@
|
||||
[submodule "app/static/javascripts/term.js"]
|
||||
path = app/static/javascripts/term.js
|
||||
[submodule "butterfly/static/javascripts/term.js"]
|
||||
path = butterfly/static/javascripts/term.js
|
||||
url = git@github.com:paradoxxxzero/term.js.git
|
||||
|
||||
@@ -39,7 +39,7 @@ log.debug('Starting server')
|
||||
ioloop = tornado.ioloop.IOLoop.instance()
|
||||
|
||||
|
||||
from app import application
|
||||
from butterfly import application
|
||||
application.listen(tornado.options.options.port)
|
||||
|
||||
|
||||
@@ -54,9 +54,9 @@ except ImportError:
|
||||
else:
|
||||
sporadic_reload({'url': url})
|
||||
|
||||
files = ['app/static/javascripts/',
|
||||
'app/static/stylesheets/',
|
||||
'app/templates/']
|
||||
files = ['butterfly/static/javascripts/',
|
||||
'butterfly/static/stylesheets/',
|
||||
'butterfly/templates/']
|
||||
watch({'url': url}, files, unwatch_at_exit=True)
|
||||
|
||||
log.debug('Starting loop')
|
||||
@@ -3,7 +3,7 @@ Description=Butterfly Terminal Server
|
||||
After=syslog.target
|
||||
|
||||
[Service]
|
||||
ExecStart=/usr/bin/butterfly.py
|
||||
ExecStart=/usr/bin/butterfly.server.py
|
||||
Restart=on-abort
|
||||
|
||||
[Install]
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
__version__ = '1.0'
|
||||
__version__ = '1.0.1'
|
||||
|
||||
|
||||
import os
|
||||
@@ -51,4 +51,4 @@ class Route(tornado.web.RequestHandler):
|
||||
return log
|
||||
|
||||
|
||||
import app.routes
|
||||
import butterfly.routes
|
||||
@@ -26,7 +26,7 @@ import tornado.websocket
|
||||
import tornado.process
|
||||
import tornado.ioloop
|
||||
import tornado.options
|
||||
from app import url, Route
|
||||
from butterfly import url, Route
|
||||
|
||||
ioloop = tornado.ioloop.IOLoop.instance()
|
||||
|
||||
@@ -122,16 +122,31 @@ class TermWebSocket(Route, tornado.websocket.WebSocketHandler):
|
||||
|
||||
@property
|
||||
def uid(self):
|
||||
with open('/proc/net/tcp') as k:
|
||||
lines = k.readlines()
|
||||
for line in lines:
|
||||
# Look for local address with peer port
|
||||
if line.split()[1] == '0100007F:%X' % self.port:
|
||||
# We got the user
|
||||
return int(line.split()[7])
|
||||
try:
|
||||
with open('/proc/net/tcp') as k:
|
||||
lines = k.readlines()
|
||||
for line in lines:
|
||||
# Look for local address with peer port
|
||||
if line.split()[1] == '0100007F:%X' % self.port:
|
||||
# We got the user
|
||||
return int(line.split()[7])
|
||||
except:
|
||||
pass
|
||||
try:
|
||||
with open('/proc/net/tcp6') as k:
|
||||
lines = k.readlines()
|
||||
for line in lines:
|
||||
# Look for local address with peer port
|
||||
if line.split()[1] == (
|
||||
'00000000000000000000000001000000:%X' % self.port):
|
||||
# We got the user
|
||||
return int(line.split()[7])
|
||||
except:
|
||||
pass
|
||||
|
||||
def open(self, user, path):
|
||||
self.bind, self.port = self.ws_connection.stream.socket.getpeername()
|
||||
self.bind, self.port = (
|
||||
self.ws_connection.stream.socket.getpeername()[:2])
|
||||
self.log.info('Websocket opened for %s:%d' % (self.bind, self.port))
|
||||
self.set_nodelay(True)
|
||||
self.user = user.decode('utf-8') if user else None
|
||||
|
Before Width: | Height: | Size: 699 B After Width: | Height: | Size: 699 B |
|
Before Width: | Height: | Size: 61 KiB After Width: | Height: | Size: 61 KiB |
6
dev.py
6
dev.py
@@ -7,9 +7,9 @@ import sys
|
||||
import shlex
|
||||
|
||||
commands = [
|
||||
'coffee -wcb -j app/static/javascripts/main.js ' +
|
||||
' '.join(glob('app/static/coffees/*.coffee')),
|
||||
'compass watch app/static',
|
||||
'coffee -wcb -j butterfly/static/javascripts/main.js ' +
|
||||
' '.join(glob('butterfly/static/coffees/*.coffee')),
|
||||
'compass watch butterfly/static',
|
||||
'python butterfly.py ' + ' '.join(sys.argv[1:])
|
||||
]
|
||||
|
||||
|
||||
11
setup.py
11
setup.py
@@ -9,7 +9,7 @@ import re
|
||||
from setuptools import setup
|
||||
|
||||
ROOT = os.path.dirname(__file__)
|
||||
with open(os.path.join(ROOT, 'app', '__init__.py')) as fd:
|
||||
with open(os.path.join(ROOT, 'butterfly', '__init__.py')) as fd:
|
||||
__version__ = re.search("__version__ = '([^']+)'", fd.read()).group(1)
|
||||
|
||||
options = dict(
|
||||
@@ -22,12 +22,11 @@ options = dict(
|
||||
url="http://github.com/paradoxxxzero/butterfly",
|
||||
license="GPLv3",
|
||||
platforms="Any",
|
||||
scripts=['butterfly.py'],
|
||||
packages=['app'],
|
||||
scripts=['butterfly.server.py'],
|
||||
packages=['butterfly'],
|
||||
install_requires=["tornado"],
|
||||
package_dir={'butterfly': 'app'},
|
||||
package_data={
|
||||
'app': [
|
||||
'butterfly': [
|
||||
'static/fonts/*',
|
||||
'static/stylesheets/main.css',
|
||||
'static/javascripts/term.js/src/term.js',
|
||||
@@ -39,7 +38,7 @@ options = dict(
|
||||
"Development Status :: 4 - Beta",
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: GNU General Public License v3 (GPLv3)",
|
||||
"Operating System :: Linux",
|
||||
"Operating System :: POSIX :: Linux",
|
||||
"Programming Language :: Python :: 2",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Topic :: Terminals"])
|
||||
|
||||
Reference in New Issue
Block a user