Skip to content

Commit

Permalink
Initial version
Browse files Browse the repository at this point in the history
  • Loading branch information
conwnet committed Jan 11, 2019
0 parents commit b4aa2f0
Show file tree
Hide file tree
Showing 34 changed files with 6,455 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
*.pyc
*.pyo
.DS*
.pylint_rc
/.idea
/.project
/.pydevproject
/.settings
Thumbs.db
*~
.cache
20 changes: 20 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
language: python
matrix:
include:
- python: "2.6"
- python: "2.7"
- python: "2.7.10"
- python: "2.7.11"
allow_failures:
- python: "3.2"
- python: "3.3"
- python: "3.4"
- python: "3.5"
- python: "nightly"

# command to install dependencies
install:
- pip install python-dateutil pytest
# command to run tests
script: py.test -v

21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The MIT License (MIT)

Copyright (c) 2019 Guoqing Zhang <[email protected]> (conw.net)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Shadowsocks-kodi

Run Shadowsocks on kodi!

26 changes: 26 additions & 0 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<addon id="service.sslocal" name="Shadowsocks" version="0.0.1" provider-name="netcon">
<requires>
<import addon="xbmc.python" version="2.24.0"/>

<import addon="script.module.simplejson" version="3.3.0"/>
</requires>
<extension point="xbmc.service" library="main.py" start="startup"/>
<extension point="xbmc.addon.metadata">
<summary>Shadowsocks Client</summary>
<description></description>
<language></language>
<platform>linux</platform>
<license>MIT</license>
<forum></forum>
<website>conw.net</website>
<email>[email protected]</email>
<source></source>
<news></news>
<disclaimer></disclaimer>
<assets>
<icon>resources/icon.png</icon>
<fanart>resources/fanart.jpg</fanart>
</assets>
</extension>
</addon>
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
v0.0.1
- Initial version
9 changes: 9 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# run service

from resources import service

if __name__ == '__main__':
service.run()

Empty file added resources/__init__.py
Empty file.
93 changes: 93 additions & 0 deletions resources/service.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# shadowsocks service

from __future__ import absolute_import, division, print_function, \
with_statement

import sys
import os
import logging
import xbmcaddon

from shadowsocks import eventloop, tcprelay, udprelay, asyncdns

config = {
'log-file': '/var/log/shadowsocks.log',
'verbose': False,
'tunnel_remote_port': 53,
'libmbedtls': None,
'tunnel_port': 53,
'local_port': 1080,
'workers': 1,
'fast_open': False,
'server_port': 8388,
'local_address': '127.0.0.1',
'method': 'aes-256-cfb',
'libsodium': None,
'tunnel_remote': '8.8.8.8',
'crypto_path': {
'mbedtls': None,
'openssl': None,
'sodium': None
},
'password': '',
'libopenssl': None,
'dns_server': None,
'prefer_ipv6': False,
'port_password': None,
'server': 'bash.pub',
'timeout': 300,
'one_time_auth': False
}

def check_python():
info = sys.version_info
if info[0] == 2 and not info[1] >= 6:
print('Python 2.6+ required')
sys.exit(1)
elif info[0] == 3 and not info[1] >= 3:
print('Python 3.3+ required')
sys.exit(1)
elif info[0] not in [2, 3]:
print('Python version not supported')
sys.exit(1)

def run():
check_python()

# fix py2exe
# in fact, i don't think this may run on windows
if hasattr(sys, "frozen") and sys.frozen in \
("windows_exe", "console_exe"):
p = os.path.dirname(os.path.abspath(sys.executable))
os.chdir(p)

addon = xbmcaddon.Addon()
config['server'] = addon.getSetting('server_addr')
config['server_port'] = int(addon.getSetting('server_port'))
config['method'] = addon.getSetting('method')
config['password'] = addon.getSetting('password')
config['local_address'] = addon.getSetting('local_addr')
config['local_port'] = int(addon.getSetting('local_port'))
config['timeout'] = int(addon.getSetting('timeout'))
config['one_time_auto'] = addon.getSetting('one_time_auto') == 'True'
config['fast_open'] = addon.getSetting('tcp_fast_open') == 'True'

if config['server'] == '':
logging.error('No SERVER_ADDR specified')
sys.exit(1)

logging.info("starting local at %s:%d" %
(config['local_address'], config['local_port']))

dns_resolver = asyncdns.DNSResolver()
tcp_server = tcprelay.TCPRelay(config, dns_resolver, True)
udp_server = udprelay.UDPRelay(config, dns_resolver, True)
loop = eventloop.EventLoop()
dns_resolver.add_to_loop(loop)
tcp_server.add_to_loop(loop)
udp_server.add_to_loop(loop)

loop.run()

18 changes: 18 additions & 0 deletions resources/settings.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
<?xml version="1.0" encoding="utf-8" standalone="yes"?>
<settings>
<category label="Necessary">
<setting label="Necessary Parameters" type="lsep" />
<setting label="SERVER_ADDR" id="server_addr" type="text" />
<setting label="SERVER_PORT" id="server_port" type="number" default="8388" />
<setting label="METHOD" id="method" type="select" default="aes-256-cfb" values="aes-128-gcm|aes-192-gcm|aes-256-gcm|aes-128-cfb|aes-192-cfb|aes-256-cfb|aes-128-ctr|aes-192-ctr|aes-256-ctr|camellia-128-cfb|camellia-192-cfb|camellia-256-cfb|bf-cfb|chacha20-ietf-poly1305|xchacha20-ietf-poly1305|salsa20|chacha20|chacha20-ietf|rc4-md5" />
<setting label="PASSWORD" id="password" type="text" option="hidden" default="" />
</category>
<category label="Optional">
<setting label="Optional Parameters" type="lsep" />
<setting label="LOCAL_ADDR" id="local_addr" type="text" default="127.0.0.1" />
<setting label="LOCAL_PORT" id="local_port" type="number" default="1080" />
<setting label="TIMEOUT" id="timeout" type="number" default="300" />
<setting label="ONE_TIME_AUTH" id="one_time_auto" type="bool" default="false" />
<setting label="TCP_FASTOPEN" id="tcp_fast_open" type="bool" default="false" />
</category>
</settings>
18 changes: 18 additions & 0 deletions shadowsocks/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/usr/bin/python
#
# Copyright 2012-2015 clowwindy
#
# Licensed under the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License. You may obtain
# a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations
# under the License.

from __future__ import absolute_import, division, print_function, \
with_statement
Loading

0 comments on commit b4aa2f0

Please sign in to comment.