我正在努力为 docker swarm 连接打开一个端口 2377。
Mac OSX 规范:
System Version: macOS 10.15.2 (19C57)
Kernel Version: Darwin 19.2.0
Run Code Online (Sandbox Code Playgroud)
我尝试打开端口的方法有很多:
使用 System Preferences->Security and Privacy-> Firewall 启用防火墙。然后编辑/etc/pf.conf如下文件,这根本没有帮助:
pass in proto tcp from any to any port 2377
pass in proto tcp from any to any port 8080
Run Code Online (Sandbox Code Playgroud)
启用和禁用防火墙后,之前启用的端口 8080 被禁用,并且找不到任何方法重新启用它。
ufw 已弃用,似乎不再起作用。
nc -l 8080 (netcat 根本没用,从来没有工作过)。
PFCTL(不工作):
HQTML git:(AD-14024)$ sudo pfctl -f /etc/pf.conf
pfctl: Use of -f option, could result in flushing of rules
present in the main ruleset …Run Code Online (Sandbox Code Playgroud)我有一个非常简单的 java 类来使用递归方法解决解码方法。我看到条件运算符的这种奇怪行为,
package decodeways;
public class Solution {
public static void main(String[] args) {
System.out.println(numDecodings("1456"));
}
public static int numDecodings(String s) {
if(s.length()>0 && s.charAt(0)=='0')
return 0;
if(s.length()==0) return 1;
if(s.length()==1)
return 1;
int num1 = s.charAt(0)-'0';
int num2 = s.charAt(1)-'0';
int one = numDecodings(s.substring(1));
int two = s.length()>1?numDecodings(s.substring(2)):0;
int res = one
+ num1<3 && num2<7 ? two:0;
return res;
}
}
Run Code Online (Sandbox Code Playgroud)
如果我加上括号,(num1<3 && num2<7 ? two:0)那么一切都很好,但是如果我去掉括号,就会得到不正确的结果。
在调试过程中,一个计算为1,两个计算为1,res也为1,带括号,但没有括号,res的计算结果将为0(附截图),这是错误的来源.
我知道 java …