Skip to content

Commit

Permalink
bugfix: Windows 通过 IPv6 远程执行命令报错:Can't find a valid stringBinding to …
Browse files Browse the repository at this point in the history
…connect (fixed #1251)
  • Loading branch information
ZhuoZhuoCrayon committed Dec 22, 2022
1 parent 219377b commit 0fb6c7e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
3 changes: 2 additions & 1 deletion apps/backend/agent/solution_maker.py
Original file line number Diff line number Diff line change
Expand Up @@ -684,6 +684,7 @@ def get_run_cmd_base_params(self) -> typing.List[str]:
host_identity: str = (self.identity_data.password, self.identity_data.key)[
self.identity_data.auth_type == constants.AuthType.KEY
]
login_ip: str = basic.compressed_ip(self.host.login_ip or self.host.inner_ip or self.host.inner_ipv6)
run_cmd_params: typing.List[str] = [
# 文件下载 / 回调服务信息
f"-l {self.gse_servers_info['package_url']}",
Expand All @@ -701,7 +702,7 @@ def get_run_cmd_base_params(self) -> typing.List[str]:
f"-HI '{host_identity}'",
f"-HP {self.identity_data.port}",
f"-HA {self.identity_data.account}",
f"-HLIP {self.host.login_ip or self.host.inner_ip or self.host.inner_ipv6}",
f"-HLIP {login_ip}",
# 目标机器安装配置
f"-HDD '{self.dest_dir}'",
# 代理机器配置
Expand Down
5 changes: 3 additions & 2 deletions apps/backend/utils/wmi.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,15 @@
an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
specific language governing permissions and limitations under the License.
"""
from apps.utils import basic
from script_tools.wmiexec import WMIEXEC


def put_file(src_file, des_path, des_ip, username, password, domain="", share="ADMIN$"):
"""upload file"""
cmd_str = "put " + str(src_file) + " " + str(des_path)
executor = WMIEXEC(cmd_str, username, password, domain, share=share)
executor.run(des_ip)
executor.run(basic.compressed_ip(des_ip))
return {
"result": True,
"data": "upload {} success to {}:{}".format(src_file, des_ip, des_path),
Expand All @@ -25,5 +26,5 @@ def put_file(src_file, des_path, des_ip, username, password, domain="", share="A
def execute_cmd(cmd_str, ipaddr, username, password, domain="", share="ADMIN$", no_output=False):
"""execute command"""
executor = WMIEXEC(cmd_str, username, password, domain, share=share, noOutput=no_output)
result_data = executor.run(ipaddr)
result_data = executor.run(basic.compressed_ip(ipaddr))
return {"result": True, "data": result_data}
3 changes: 3 additions & 0 deletions dev_log/2.2.32/crayon_202211211658.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
---
bugfix:
- "Windows 通过 IPv6 远程执行命令报错:Can't find a valid stringBinding to connect (fixed #1251)"

0 comments on commit 0fb6c7e

Please sign in to comment.