- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我们有一个 Windows 服务器和一个 Linux 服务器。两台服务器上都没有互联网。现在,我们需要在这些服务器上部署一个 python 脚本,它将向外部网络 url 发出 http get 请求。所以,我需要互联网。但我们无法为所有应用程序启用互联网。有没有办法只为这个特定的脚本启用互联网?
最佳答案
我不太了解 Linux 平台,但您可以允许程序使用命令行发出传出请求,像这样从 python 中:
import sys
import os
def allow_outbound_connections(program_path):
"""
Allow program outbound connections.
"""
if "win" in sys.platform:
command = f'netsh advfirewall firewall add rule name="{program_path}" '\
'dir=out action=block program= "{os.path.basename(program_path}"'\
' enable=yes profile=any'
if "linux" in sys.platform:
# *Add a similar command in Linux*
with os.popen(command) as stream:
return stream.read()
def main():
# First allow this program to make outbound connections.
output = allow_outbound_connections(__file__)
# (Eventually you could handle the output)
# Now make request to an outside network url.
关于linux - 将上网脚本列入白名单,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52217194/
需要检查并修改如下的四个文件,如果文件不存在,则手工创建该文件: 1. /etc/hosts 2./etc/resolv.conf 3./etc/defaultrouter 4./etc/n
我正在尝试在 Anrdoid M 中执行 HTTP 请求。但每次我收到错误: java.lang.SecurityException: Permission denied (missing INTER
我正在 android 上尝试 twitter4j(这两个都是新的),用 java 编写了一个简单的过程只是为了测试它。它下载用户时间线并打印到屏幕上。 我修改了 Android 的代码,但当我尝试下
我正在开发一个使用 WIFI 连接到硬件设备的应用程序。基本上,该设备会创建一个用于与其通信的 wifi 网络。 问题是这个设备不是路由器,不提供互联网连接。因此,当我使用 wifi 连接连接到此设备
首先,我正在寻找使用私有(private) API 的资源。这是一个企业应用程序,永远不会去应用商店我需要尽可能多地让用户进行配置。 也就是说,我有一个设备,iPad 将连接到该设备并通过该设备提供的
我是一名优秀的程序员,十分优秀!