Giter VIP home page Giter VIP logo

pysoftether's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

pysoftether's Issues

socket.gaierror: [Errno 11001] getaddrinfo failed

I am hoping to automate SoftEthernet VPN Client Manager with python.

When I am running the example, but it failed on me. When I duckduckgoed the Errno 11001 I didn't understand it.

The errormessage I got:

Traceback (most recent call last):
File "C:\Users\emiel \Documents\programmeren\lente2020\webscraping python\JapanRulezDem.py", line 10, in
api.connect()
File "C:\Users\emiel \AppData\Local\Programs\Python\Python36\lib\site-packages\softether\api.py", line 102, in connect
self.socket.connect()
File "C:\Users\emiel \AppData\Local\Programs\Python\Python36\lib\site-packages\softether\api.py", line 29, in connect
self.socket.connect((self.host, self.port))
File "C:\Users\emiel \AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1100, in connect
self._real_connect(addr, False)
File "C:\Users\emiel \AppData\Local\Programs\Python\Python36\lib\ssl.py", line 1087, in _real_connect
socket.connect(self, addr)
socket.gaierror: [Errno 11001] getaddrinfo failed
[Finished in 0.8s]

Authenticate not working

Hello,

When I run api.authenticate() I get the following issues

Traceback (most recent call last):
  File "/usr/lib/python3.5/hashlib.py", line 122, in __hash_new
    return _hashlib.new(name, data)
ValueError: unsupported hash type

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/softether/api.py", line 129, in authenticate
    hashed_password = hashlib.new('sha')
  File "/usr/lib/python3.5/hashlib.py", line 128, in __hash_new
    return __get_builtin_constructor(name)(data)
  File "/usr/lib/python3.5/hashlib.py", line 95, in __get_builtin_constructor
    raise ValueError('unsupported hash type ' + name)
ValueError: unsupported hash type sha

SoftEtherAPIException when virtual hub has more than 100 users

  File "main.py", line 14, in <module>
    all_users = set(vpn.get_all_users(hub))
  File "/app/vpnserver.py", line 46, in get_all_users
    users = self.api.enum_user(hub_name=virtualhub)
  File "/usr/local/lib/python3.5/dist-packages/softether/api.py", line 676, in enum_user
    return self.call_method('EnumUser', payload)
  File "/usr/local/lib/python3.5/dist-packages/softether/api.py", line 187, in call_method
    raise SoftEtherAPIException('api_call_wrong_response_length')
softether.api.SoftEtherAPIException: api_call_wrong_response_length

Possible bugs in get/set_secure_nat_option

I can not do get/set_secure_nat_option with current api. I did a quick check:

class MySoftEtherAPI(SoftEtherAPI):

    def get_secure_nat_option(self, hub_name=None):
        payload = {
            'RpcHubName': ('string', [hub_name]),
        }

        return self.call_method('GetSecureNATOption', payload)

    def set_secure_nat_option(self, hub_name=None, use_nat=1, use_dhcp=1,
                              save_log=1, apply_dhcp_push_routes=1,
                              mac_address=None, ip=None, mask=None,
                              mtu=0, nat_tcp_timeout=0, nat_udp_timeout=0,
                              dhcp_lease_ip_start=0, dhcp_lease_ip_end=0,
                              dhcp_subnet_mask=0, dhcp_expire_time_span=0,
                              dhcp_gateway_address=0,
                              dhcp_dns_server_address=0,
                              dhcp_dns_server_address2=0,
                              dhcp_domain_name="",
                              dhcp_push_routes=""):
        payload = {
            'MacAddress': ('raw', [mac_address]),
            'Ip': ('int', [ip]),
            'Mask': ('int', [mask]),
            'UseNat': ('int', [use_nat]),
            'Mtu': ('int', [mtu]),
            'NatTcpTimeout': ('int', [nat_tcp_timeout]),
            'NatUdpTimeout': ('int', [nat_udp_timeout]),
            'UseDhcp': ('int', [use_dhcp]),
            'DhcpLeaseIPStart': ('int', [dhcp_lease_ip_start]),
            'DhcpLeaseIPEnd': ('int', [dhcp_lease_ip_end]),
            'DhcpSubnetMask': ('int', [dhcp_subnet_mask]),
            'DhcpExpireTimeSpan': ('int', [dhcp_expire_time_span]),
            'DhcpGatewayAddress': ('int', [dhcp_gateway_address]),
            'DhcpDnsServerAddress': ('int', [dhcp_dns_server_address]),
            'DhcpDnsServerAddress2': ('int', [dhcp_dns_server_address2]),
            'DhcpDomainName': ('string', [dhcp_domain_name]),
            'SaveLog': ('int', [save_log]),
            'RpcHubName': ('string', [hub_name]),
            'ApplyDhcpPushRoutes': ('int', [apply_dhcp_push_routes]),
            'DhcpPushRoutes': ('string', [dhcp_push_routes])
        }

        return self.call_method('SetSecureNATOption', payload)

get_secure_nat_option original use 'HubName in payload, which doesn't work. The code above does work.

So I think changing it in set_secure_nat_option should work, but it doesn't. I always get ERR_INVALID_PARAMETER. Here's relevant output:

{u'ApplyDhcpPushRoutes': [1],
 u'DhcpDnsServerAddress': [18786496],
 u'DhcpDnsServerAddress2': [0],
 u'DhcpDnsServerAddress2@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpDnsServerAddress2@ipv6_bool': [0],
 u'DhcpDnsServerAddress2@ipv6_scope_id': [0],
 u'DhcpDnsServerAddress@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpDnsServerAddress@ipv6_bool': [0],
 u'DhcpDnsServerAddress@ipv6_scope_id': [0],
 u'DhcpDomainName': [u''],
 u'DhcpExpireTimeSpan': [7200],
 u'DhcpGatewayAddress': [18786496],
 u'DhcpGatewayAddress@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpGatewayAddress@ipv6_bool': [0],
 u'DhcpGatewayAddress@ipv6_scope_id': [0],
 u'DhcpLeaseIPEnd': [3357452480],
 u'DhcpLeaseIPEnd@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpLeaseIPEnd@ipv6_bool': [0],
 u'DhcpLeaseIPEnd@ipv6_scope_id': [0],
 u'DhcpLeaseIPStart': [169781440],
 u'DhcpLeaseIPStart@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpLeaseIPStart@ipv6_bool': [0],
 u'DhcpLeaseIPStart@ipv6_scope_id': [0],
 u'DhcpPushRoutes': [u''],
 u'DhcpSubnetMask': [16777215],
 u'DhcpSubnetMask@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'DhcpSubnetMask@ipv6_bool': [0],
 u'DhcpSubnetMask@ipv6_scope_id': [0],
 u'Ip': [18786496],
 u'Ip@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'Ip@ipv6_bool': [0],
 u'Ip@ipv6_scope_id': [0],
 u'MacAddress': ['^J\xd8hP\x92'],
 u'Mask': [16777215],
 u'Mask@ipv6_array': ['\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00'],
 u'Mask@ipv6_bool': [0],
 u'Mask@ipv6_scope_id': [0],
 u'Mtu': [1500],
 u'NatTcpTimeout': [1800],
 u'NatUdpTimeout': [60],
 u'RpcHubName': [u''],
 u'SaveLog': [1],
 u'UseDhcp': [1],
 u'UseNat': [1]}
ERROR:root:{u'error': ['ERR_INVALID_PARAMETER']}

You can see in get output, RpcHubName is empty. So is it the API which use wrong params, or the server which have bug in parsing the input?

The SoftetherVPN I used is stable version, 4.29 build 6280

Usage example error

Hello I just tried to run Usage examplebut ı got this error :
api = SoftEtherAPI("vpn180780571.softether.net", 443, 'mypassword')

Traceback (most recent call last):
  File "C:/Users/Fatih/PycharmProjects/VPNControl/Test.py", line 5, in <module>
    api.connect()
  File "C:\Users\Fatih\PycharmProjects\VPNControl\venv\lib\site-packages\softether\api.py", line 103, in connect
    self.socket.connect()
  File "C:\Users\Fatih\PycharmProjects\VPNControl\venv\lib\site-packages\softether\api.py", line 30, in connect
    self.socket.connect((self.host, self.port))
  File "C:\Users\Fatih\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 1172, in connect
    self._real_connect(addr, False)
  File "C:\Users\Fatih\AppData\Local\Programs\Python\Python37-32\lib\ssl.py", line 1159, in _real_connect
    super().connect(addr)
TimeoutError: [WinError 10060] A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.