-
Notifications
You must be signed in to change notification settings - Fork 264
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
changed _build_url to include ability to parse ipv6 host with bracket… #92
base: master
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a chance of getting this in? or something that needs to be changed? I am willing to make them to get this in.
>>> import re
>>> import winrm
>>> class v6Session(winrm.Session):
... @staticmethod
... def _build_url(target, transport):
... match = re.match(
... '(?i)^((?P<scheme>http[s]?)://)?(?P<host>[0-9a-z-_.]+|\[[0-9a-f:]+])(:(?P<port>\d+))?(?P<path>(/)?(wsman)?)?', target)
... groups = match.groupdict()
... if groups['scheme'] is None:
... groups['scheme'] = 'https' if transport == 'ssl' else 'http'
... if groups['port'] is None:
... groups['port'] = 5986 if transport == 'ssl' else 5985
... if not groups['path']:
... groups['path'] = 'wsman'
... return '{scheme}://{host}:{port}/{path}'.format(**groups)
...
>>> c = winrm.Session('[****]', auth=('Administrator','****'))
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/lib/python2.7/site-packages/winrm/__init__.py", line 31, in __init__
self.url = self._build_url(target, kwargs.get('transport', 'plaintext'))
File "/usr/lib/python2.7/site-packages/winrm/__init__.py", line 106, in _build_url
scheme = match.group('scheme')
AttributeError: 'NoneType' object has no attribute 'group'
>>> c = v6Session('[****]', auth=('Administrator','****'))
>>> c.run_cmd('ver')
<Response code 0, out "
Microsoft Windows ", err "">
@@ -94,7 +94,7 @@ def strip_namespace(self, xml): | |||
@staticmethod | |||
def _build_url(target, transport): | |||
match = re.match( | |||
'(?i)^((?P<scheme>http[s]?)://)?(?P<host>[0-9a-z-_.]+)(:(?P<port>\d+))?(?P<path>(/)?(wsman)?)?', target) # NOQA | |||
'(?i)^((?P<scheme>http[s]?)://)?(?P<host>\[[0-9A-Fa-f:]+]|[0-9a-z-_.]+)(:(?P<port>\d+))?(?P<path>(/)?(wsman)?)?', target) # NOQA |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the A-F
is not needed as this is already case insensitive.
@badcure @nitzmahone: Is there anything more that needs to be done to incorporate this work? |
These changes do allow me to run winrm with ipv6, any chance of getting this merged? |
… notation