Commit 9e19589b authored by Yury's avatar Yury

Docker image

parent f196670b
Pipeline #119 canceled with stages
in 4 minutes and 30 seconds
stages:
- unittests
- build
- docker_build
tests:
stage: unittests
......@@ -21,7 +22,15 @@ pypi_build:
- apk update
- apk add --update --no-cache --virtual .build-deps alpine-sdk python3-dev musl-dev postgresql-dev libffi-dev
- pip3 install -U setuptools pip twine
- python3 generate_setup.py
- python3 setup.py sdist
- twine upload dist/*
- pip3 install neptune_resolver_redis
docker_build:
stage: docker_build
tags:
- docker
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE" .
- docker push "$CI_REGISTRY_IMAGE"
only:
- master
\ No newline at end of file
FROM python:3
ENV PYTHONUNBUFFERED 1
RUN mkdir /saturn_socks5_server
WORKDIR /saturn_socks5_server
ADD requirements.txt /saturn_socks5_server/
ADD /saturn /saturn_socks5_server/saturn/
ADD setup.py /saturn_socks5_server/
RUN pip install -r requirements.txt
ENV PYTHONPATH /saturn_socks5_server/
CMD [ "python", "saturn" ]
\ No newline at end of file
from saturn import start_server
import sys
def get_argv(index, default=None):
try:
return sys.argv[index]
......
import random
import socket
from ipaddress import IPv4Address
from saturn import protocol
from saturn import state
from saturn.protocol.client_tcp import TcpClient
class SocksHello(SocksPacket):
def __init__(self, dispatcher, data):
super().__init__(data)
self.dispatcher = dispatcher
self.nmethods = data[1]
self.methods = [x for x in data[2:2 + self.nmethods]]
def reply(self):
for m in self.dispatcher.server.server_auth_methods:
if m in self.methods:
self.dispatcher.state = state.WaitingAuthenticationData(
method=m) if not m == 0 else state.Authenticated()
return self.ver.to_bytes(1, byteorder='big') + int.to_bytes(m, 1, byteorder='big')
return self.ver.to_bytes(1, byteorder='big') + int.to_bytes(255, 1, byteorder='big')
class SocksAuthenticate:
def __init__(self, dispatcher, data):
self.data = data
self.dispatcher = dispatcher
self.server = dispatcher.server
async def authenticate(self):
if await self.server.auth(self.dispatcher.state.method, self.data):
self.dispatcher.state = state.Authenticated()
return int(1).to_bytes(1, byteorder='big') + int(0).to_bytes(1, byteorder='big')
return int(1).to_bytes(1, byteorder='big') + int(10).to_bytes(1, byteorder='big')
class SocksRequestBind(SocksRequest):
def __init__(self, dispatcher, data):
assert len(data) >= 10
super().__init__(dispatcher, data)
async def go(self):
on_connect = self.dispatcher.loop.create_future()
try:
self.dispatcher.client_transport, self.client_protocol = await self.dispatcher.loop.create_connection(
lambda: TcpClient(self.dispatcher, on_connect),
str(self.dst_addr), self.dst_port)
except OSError as e:
print(e.errno, e)
try:
port = random.randrange(30000, 65535)
self.dispatcher.loop.create_task(
protocol.TcpServer(self, self.dispatcher.loop).start_server(self.host, port))
except OSError as e:
print(e.errno, e)
return SocksTcpReply(self.dispatcher, 5, 0, 0, 1, int(IPv4Address(socket.gethostbyname(socket.gethostname()))),
port)
class SocksRequestUdpAssociate(SocksRequest):
async def go(self):
print('wooops2')
__version__ = "0.3"
\ No newline at end of file
__version__ = "0.5"
\ No newline at end of file
......@@ -3,7 +3,7 @@ from setuptools import setup, find_packages
setup(
name='saturn_proxy_server', # How you named your package folder (MyLib)
packages=find_packages(exclude=['*.tests', '*.tests.*', 'tests.*', 'tests']), # Chose the same as "name"
version='0.3', # Start with a small number and increase it with every change you make
version='0.5', # Start with a small number and increase it with every change you make
license='MIT', # Chose a license from here: https://help.github.com/articles/licensing-a-repository
long_description='''# Socks5 async proxy server
Saturn is a SOCKS5 server based on asyncio protocols
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment