changed _build_url to include ability to parse ipv6 host with bracket…#92
Open
lawrencellui-dd wants to merge 2 commits intodiyan:masterfrom
Open
changed _build_url to include ability to parse ipv6 host with bracket…#92lawrencellui-dd wants to merge 2 commits intodiyan:masterfrom
lawrencellui-dd wants to merge 2 commits intodiyan:masterfrom
Conversation
Closed
stuartgh
reviewed
Dec 20, 2019
There was a problem hiding this comment.
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 "">
| 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.
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? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
… notation