Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pyrad + python3.6 #73

Open
velopokatun opened this issue Jan 18, 2018 · 6 comments
Open

pyrad + python3.6 #73

velopokatun opened this issue Jan 18, 2018 · 6 comments
Assignees
Labels
feedback feedback required fixed

Comments

@velopokatun
Copy link

Good afternoon. I used your wonderful library in python 2.7.It's time to move to 3.6 and asyncio and ran into this problem.


import pyrad.packet
from pyrad.dictionary import Dictionary
from pyrad.client import Client

srv = Client(
    server='localhost',
    secret=b'test',
    dict=Dictionary('/opt//dictionary')
)

req = srv.CreateAuthPacket(
    code=pyrad.packet.AccessRequest,
    User_Name='xxxxx',
)
req["User-Password"] = req.PwCrypt('yyyyy')
req['NAS-Identifier'] = 'node'
req['NAS-IP-Address'] = '0.0.0.0'

reply = srv.SendPacket(req)

'''
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.6/dist-packages/pyrad/client.py", line 173, in SendPacket
    return self._SendPacket(pkt, self.authport)
  File "/usr/local/lib/python3.6/dist-packages/pyrad/client.py", line 137, in _SendPacket
    self._socket.sendto(pkt.RequestPacket(), (self.server, port))
socket.gaierror: [Errno -2] Name or service not known

'''
Tell me please what this means, since the conclusion about anything does not tell me

@rbricheno
Copy link
Contributor

rbricheno commented Apr 10, 2018

It looks like the computer where you are running python can't resolve localhost.

I expect if you run this python snippet you will receive the same error:

import socket

print(socket.gethostbyname("localhost"))

Troubleshoot that before looking at pyrad (e.g. is there an entry for localhost in your hosts file? what happens when you run a command like nslookup localhost?)

@velopokatun
Copy link
Author

~$ python2.7

import socket
print(socket.gethostbyname("localhost"))
127.0.0.1

~$ python3.6

import socket
print(socket.gethostbyname("localhost"))
127.0.0.1

~$ nslookup localhost
Server: 127.0.0.1
Address: 127.0.0.1#53

Non-authoritative answer:
Name: localhost
Address: 127.0.0.1
`

@rbricheno
Copy link
Contributor

Thank you, that's quite interesting. The only way I could replicate your problem was by breaking my ability to resolve localhost. I'd like to try and find a minimal case that still breaks for you. Does this break, or does it work?

import socket

my_socket = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
my_socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
my_socket.sendto(b'a', ("localhost", 1812))

That should be very close to what pyrad is doing (and works for me with no error).

Also, could you comment about what platform you are using please? E.g. windows, mac, linux distribution / version?

@velopokatun
Copy link
Author

Sorry for the late response. The project slowed down a bit and the problem moved to the second row. The platform used Ubuntu 64 16.04 LTS

@velopokatun
Copy link
Author

I still replace one feature that I'm sorry, did not specify. The problem arises if the address is specified in IPV6. When IPV4 everything is working fine

@GIC-de
Copy link
Collaborator

GIC-de commented Jul 5, 2018

Please try with latest version from master which should support IPv6 as well and close issue if working.

@GIC-de GIC-de added fixed feedback feedback required labels Jul 5, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feedback feedback required fixed
Projects
None yet
Development

No branches or pull requests

3 participants