首页 \ 问答 \ 允许Web套接字的content-security-policy元标记(content-security-policy meta tag for allowing web socket)

允许Web套接字的content-security-policy元标记(content-security-policy meta tag for allowing web socket)

情况:由content-security-policy元标记阻止的phonegap serve的自动phonegap serve

添加内容安全策略可防止自动重新加载phonegap serve实用程序。 这是建立在cordova serve之上,但在文件编辑时自动重新加载应用程序。 它的工作原理是在index.html注入socket.io 。 我应该在我的CSP元标记中指定哪些内容允许套接字连接到我的笔记本电脑。

这是我目前的CSP元标记:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' 192.168.0.100 * ws:* ; connect-src ws://192.168.0.100 ws:*"> 

但是在打开时,设备会一直显示“正在连接到设备”,而不会在设备上收到事件。

另请注意,它开始处理删除此元标记,这意味着cordova-plugin-whitelist可能无法阻止它。


Situation: autoreload of phonegap serve blocked by content-security-policy meta tag

Adding content security policy prevents auto-reload of phonegap serve utility. This is built on top of cordova serve but auto-reloads the app on file editing. It works by injecting socket.io in index.html. What should I specify in my CSP meta tag that will allow socket connections to my laptop.

Here is my current CSP meta tag:

<meta http-equiv="Content-Security-Policy" content="default-src 'self' 192.168.0.100 * ws:* ; connect-src ws://192.168.0.100 ws:*"> 

However on opening, the device keeps showing "Connecting to device" and not event is received on the device.

Also note that it starts working on removing this meta tag which mean the cordova-plugin-whitelist might not be blocking it.


原文:https://stackoverflow.com/questions/32986074
更新时间:2022-02-17 09:02

最满意答案

事实证明,这些设备使用标准的Silicon Labs CP2102接口芯片,设备制造商加载了自定义idProduct编号。 虽然芯片与cp210x.ko驱动程序100%兼容,但系统无法识别idProduct ,也不会将驱动程序与其关联。

此时,有几种可能的解决方案:

  • 手动指示系统将cp210x.ko驱动程序与此idProduct一起使用。
  • idProduct添加到开源驱动程序 ,编译并安装它。 然后尝试将更改推送到标准Linux存储库。
  • 用通用芯片替换定制芯片。
  • 重写芯片上的idProduct

我选择重写idProduct 。 Silicon Labs有一个免费的实用程序可以做到这一点。 我设置了idProduct=EA60 ,这是该芯片的默认设置。 该设备现在可以通过标准内置驱动程序识别,并且工作正常。


It turns out this devices uses a standard Silicon Labs CP2102 interface chip, which the device manufacturer loaded with a custom idProduct number. While the chip is 100% compatible with the cp210x.ko driver, the idProduct is not recognized by the system, and does not associate the driver with it.

At this point, there are several possible solutions:

  • Manually direct the system to use the cp210x.ko driver with this idProduct.
  • Add the idProduct to the open source driver, compile, and install it. Then try to push the changes into standard Linux repositories.
  • Replace the customized chip with generic one.
  • Rewrite the idProduct on the chip.

I chose to rewrite the idProduct. Silicon Labs has a free utility to do just this. I set the idProduct=EA60, which is the default for this chip. The device is now recognized by the standard built-in driver, and works perfectly.

相关问答

更多
  • 您好,由于目前消费电脑大部分的驱动以及应用程序都是在windows 操作系统下开发的,还没有针对linux 系统的驱动程序,为了您电脑的正常运行,我们建议您使用windows 系统;如果您由于工作或学习需要,安装使用linux 系统,您可以到相关的专业论坛、网站上搜索相应设备的驱动程序。
  • 您可以使用pty(“伪电传”,其中串口是“真实电传”)。 从一端打开/dev/ptyp5 ,然后将程序附加到/dev/ttyp5 ; ttyp5将像串行端口一样执行,但将通过/ dev / ptyp5发送/接收它所做的一切。 如果真的需要它与一个名为/dev/ttys2的文件进行/dev/ttys2 ,那么只需将旧的/dev/ttys2从ptyp5转到ttys2 。 当然你可以使用ptyp5以外的其他ptyp5 。 也许选择一个高数字以避免重复,因为所有的登录终端也将使用ptys。 维基百科有更多关于pty ...
  • 事实证明,这些设备使用标准的Silicon Labs CP2102接口芯片,设备制造商加载了自定义idProduct编号。 虽然芯片与cp210x.ko驱动程序100%兼容,但系统无法识别idProduct ,也不会将驱动程序与其关联。 此时,有几种可能的解决方案: 手动指示系统将cp210x.ko驱动程序与此idProduct一起使用。 将idProduct添加到开源驱动程序 ,编译并安装它。 然后尝试将更改推送到标准Linux存储库。 用通用芯片替换定制芯片。 重写芯片上的idProduct 。 我选择 ...
  • 在我的头顶,它是 stty -F /dev/ttySX raw -echo -echoe -echok -echoke 从手册页中可能会有更多标志: [-]crterase echo erase characters as backspace-space-backspace * crtkill kill all line by obeying the echoprt and echoe settings * -crtkill ...
  • 尝试使用setserial设置low_latency选项。 默认情况下,串行端口针对吞吐量而非延迟进行了优化,我认为此选项可让您更改它。 Try the using setserial to set the low_latency option. By default serial ports are optimised for throughput not latency, this option I think lets you change it.
  • 你是如何获得第一个串口的文件描述符的? 假设它是这样的: fd = open("/dev/serialPort0", O_RDWR); 你应该能够做到: fd2 = open("/dev/serialPort1", O_RDWR); 并获取用于其他串行端口的文件描述符。 写下你想要的每一个: char str1[] = "Hello, port 1!\n"; char str2[] = "hello, port 2!\n"; write(fd, str1, sizeof str1); write(fd ...
  • 我的问题是我不知道应该如何理解我应该监视哪个串口。 如果这个“一个开发板”被Linux PC识别为USB小工具,则会有syslog条目。 断开电路板,等待15秒,然后连接电路板。 使用命令dmesg | tail dmesg | tail来检查syslog的结尾。 你可能得到这样的东西: $ dmesg | tail [ 2094.481014] usb 1-1: Product: EDBG CMSIS-DAP [ 2094.481019] usb 1-1: Manufacturer: Atmel Corp ...
  • 没什么区别。 一些系统可能会为某些应用程序使用termcap 库 (offhand,可能只有Slackware),但是应用程序使用相同的库,无论它是否在串行端口上运行。 有几个应用程序使用termcap 接口来访问ncurses库(它提供了termcap和terminfo接口),但这并没有改变答案。 他们仍然会使用相同的库(和相同的接口),因为在同一个库的不同低级接口之间切换几乎没有意义。 “接口”当然是指用于初始化和查询终端数据库的少数功能。 使用termcap 接口到ncurses的应用程序仍然会获得t ...
  • 不幸的是,现代伪终端并不那么容易。 在使用posix_openpt()或open("/dev/ptmx")主posix_openpt()之后,必须在主服务器及其相应的从服务器可用之前调用grantpt()和unlockpt() 。 ( openpty()等实用程序函数简化了这一点。) 作为一种解决方法,可以使用方便的社交场所 。 # terminal 1 socat pty:link=$PWD/pts unix-l:$PWD/ptm-pipe & dynamips -U $PWD/pts # termin ...
  • 您可以使用QSerialPort port("/dev/ttyUSB0")构造串行端口对象。 此QSerialPort构造函数接受它在QSerialPortInfo::portName()存在的形式的端口名称。 没有记录这个名称是"/dev/ttyUSB0"形式,但似乎是这样。 You can construct a serial port object using QSerialPort port("/dev/ttyUSB0"). This QSerialPort constructor accepts ...

相关文章

更多

最新问答

更多
  • 在ios 7中的UITableView部分周围绘制边界线(draw borderline around UITableView section in ios 7)
  • Java中的不可变类(Immutable class in Java)
  • 寻求多次出现的表达式(Seeking for more than one occurrence of an expression)
  • linux只知道文件名,不知道在哪个目录,怎么找到文件所在目录
  • Actionscript:检查字符串是否包含域或子域(Actionscript: check if string contains domain or subdomain)
  • 懒惰地初始化AutoMapper(Lazily initializing AutoMapper)
  • 使用hasclass为多个div与一个按钮问题(using hasclass for multiple divs with one button Problems)
  • Windows Phone 7:检查资源是否存在(Windows Phone 7: Check If Resource Exists)
  • EXCEL VBA 基础教程下载
  • RoR - 邮件中的动态主体(部分)(RoR - Dynamic body (part) in mailer)
  • 无法在Google Script中返回2D数组?(Can not return 2D Array in Google Script?)
  • JAVA环境变量的设置和对path , classpth ,java_home设置作用和目的?
  • mysql 关于分组查询、时间条件查询
  • 如何使用PowerShell匹配运算符(How to use the PowerShell match operator)
  • Effective C ++,第三版:重载const函数(Effective C++, Third edition: Overloading const function)
  • 如何用DELPHI动态建立MYSQL的数据库和表? 请示出源代码。谢谢!
  • 带有简单redis应用程序的Node.js抛出“未处理的错误”(Node.js with simple redis application throwing 'unhandled error')
  • 使用前端框架带来哪些好处,相对于使用jquery
  • Ruby将字符串($ 100.99)转换为float或BigDecimal(Ruby convert string ($100.99) to float or BigDecimal)
  • 高考完可以去做些什么?注意什么?
  • 如何声明放在main之后的类模板?(How do I declare a class template that is placed after the main?)
  • 如何使用XSLT基于兄弟姐妹对元素进行分组(How to group elements based on their siblings using XSLT)
  • 在wordpress中的所有页面的标志(Logo in all pages in wordpress)
  • R:使用rollapply对列组进行求和的问题(R: Problems using rollapply to sum groups of columns)
  • Allauth不会保存其他字段(Allauth will not save additional fields)
  • python中使用sys模块中sys.exit()好像不能退出?
  • 将Int拆分为3个字节并返回C语言(Splitting an Int to 3 bytes and back in C)
  • 在SD / MMC中启用DDR会导致问题吗?(Enabling DDR in SD/MMC causes problems? CMD 11 gives a response but the voltage switch wont complete)
  • sed没有按预期工作,从字符串中间删除特殊字符(sed not working as expected, removing special character from middle of string)
  • 如何将字符串转换为Elixir中的函数(how to convert a string to a function in Elixir)