小编Mik*_*ike的帖子

如何根据本地子网自动切换ssh配置?

当我在某个网络(子网是10.10.11.x)时,我需要跳过一个中间主机才能到达我的目的地,因为我无法更改目标端口和可以退出受限网络的有限端口.我使用如下的ssh配置成功:

Host web-direct web
    HostName web.example.com
    Port 1111

Host web-via-jump jweb
    HostName web.example.com
    Port 1111
    ForwardAgent yes
    ProxyCommand ssh -p 110 -q relay.example.com nc %h %p
Run Code Online (Sandbox Code Playgroud)

通过跳跃盒是一个重要的性能打击,所以我需要避免它在大多数情况下不需要它.切换ssh/scp/rsync主机昵称适合交互式使用,但有一些自动/脚本化任务非常痛苦.

我的shell在网络转换中保持开放,因此启动(.zshrc)机制无济于事.

我曾经想过运行一个脚本来轮询受限子网并通过修改.ssh/config文件来自动化交换机,但我甚至不确定会出现缓存问题.在我实施之前,我想我会问是否有更好的方法.

基于源主机子网检测交换ssh配置的最佳方法是什么?

在伪配置中,类似于:

if <any-active-local-interface> is on 10.10.11.x:
    Host web
        HostName web.example.com
        Port 1111
        ForwardAgent yes
        ProxyCommand ssh -p 110 -q relay.example.com nc %h %p
else:    
    Host web
        HostName web.example.com
        Port 1111
endif
Run Code Online (Sandbox Code Playgroud)

根据@ fedor-dikarev的回答,我创建了名为onsubnet的bash脚本:

Host web-direct web
    HostName web.example.com
    Port 1111

Host web-via-jump jweb
    HostName web.example.com
    Port 1111
    ForwardAgent yes …
Run Code Online (Sandbox Code Playgroud)

ssh

9
推荐指数
2
解决办法
1972
查看次数

如何在 Chrome DevTools 检查器的样式和计算选项卡中使用多个过滤器?

在Chrome DevTools 中检查器的Styles and Computed选项卡的Filter字段中,如何使用多个 ORed 过滤器,以便我一次可以看到更多样式?我已经尝试了我能想到的所有可能使用的字符,并在网上搜索了文档和其他地方。有这么多的属性,看到一个相关的集合,比如通常的盒子模型或弹性盒子相关的集合,会非常有用。width|height

css google-chrome google-chrome-devtools

9
推荐指数
1
解决办法
162
查看次数

如何在新的macOS版本上为旧版本创建自制瓶?

我想为Sierra创建一瓶zsh 5.1.1,因为zsh 5.2有一个非常糟糕的错误,它会破坏某些功能.

Sierra带有zsh 5.2,它可以用于多字节bindkey击键(参见:http://www.zsh.org/mla/users/2015/msg01400.html ).我已经设法在一台机器上从源代码获得5.1.1构建,但是为了更广泛的分发,在zsh的新版本发布之前,一瓶Sierra zsh 5.1.1会好得多.

该错误不仅阻止了utf-8多字节ascii字符的绑定(我使用了很多Option键组合),但如果它们具有相同的初始字节,则阻止其他字符甚至被键入.

我认为这是bug出现之前zsh配方的最后一个版本:https://github.com/Homebrew/homebrew-core/blob/1a4461ad2a0f1bc7074d9817db059147a31eeee6/Formula/zsh.rb

macos homebrew zsh oh-my-zsh

6
推荐指数
1
解决办法
1660
查看次数

在firebase中,为什么交易不像在管理员api中那样在云功能中工作?

我有现有的管理员API代码,为了测试目的,我简化了这个代码(这是有效的):

admin.database().ref('/dropbox').on('child_added', function (childSnap) {

  let item, itemRef = childSnap.ref;

  console.log(`Item: ${JSON.stringify(childSnap.val())} at ${childSnap.key}`);
  console.log(`Item ref: ${itemRef.toString()}`);

  itemRef.transaction(function (value) {
    console.log(`Value: ${JSON.stringify(value)}`);
    if (value) {
      item  = value;
      return null;
    }
  }).then(function (resolution) {
    console.log(`Txn resolution: ${resolution.committed ? 'committed' : 'NOT-COMMITTED'}`);
    if (resolution.committed) {
      // process item
      console.log(`Process: ${JSON.stringify(item)}`);
    } else {
      // assume that item must have been removed by someone else
    }
  }).catch(function (err) {
    console.log(`Txn error: ${JSON.stringify(err, null, 2)}`);
  });

});
Run Code Online (Sandbox Code Playgroud)

当我跑:

firebase数据库:push/dropbox <<<'{"test":"abc123"}'

控制台输出是:

Item: {"test":"abc123"} …
Run Code Online (Sandbox Code Playgroud)

javascript transactions firebase firebase-realtime-database google-cloud-functions

6
推荐指数
1
解决办法
2491
查看次数

Debug.WriteLine()参数表达式评估副作用是否在发布版本中发生?

根据这个问题的接受答案:

When the application is compiled in the release configuration, 
the Debug elements will not be compiled into the code.
Run Code Online (Sandbox Code Playgroud)

Debug.WriteLine()(和类似的)的参数表达式评估副作用是否在发布版本中发生?我不确定"调试元素"究竟意味着什么.

.net c# visual-studio

4
推荐指数
1
解决办法
100
查看次数

如何在firebase项目中为云功能使用"函数"以外的文件夹名称?

我的源代码组织方式使得函数成为我的云函数源位置的尴尬名称.我正在使用package.json中的"main"属性来指定源文件,但部署工具在package.json的函数中查找.我已经阅读了配置文件的所有可用文档,但没有看到云功能的任何内容.

初始化命令甚至没有在配置文件中添加部分.

firebase google-cloud-functions firebase-cloud-messaging

4
推荐指数
1
解决办法
559
查看次数

How does one automate Let’s Encrypt certificate renewal for Lighttpd?

On a Linux system running Lighttpd, how can I automate certificate renewal for Let\xe2\x80\x99s Encrypt certs. Let\xe2\x80\x99s Encrypt provides great scripts for Apache 2 and NGINX but not Lighttpd which is much more comfortable for small systems like Raspberry Pi or old boxes.

\n

lighttpd raspberry-pi lets-encrypt

2
推荐指数
1
解决办法
3026
查看次数

您如何判断onCreate firebase云功能中的用户是否“匿名”?

在我的onCreate用于Firebase处理程序的auth云函数中,如何判断用户是否匿名,例如,isAnonymous我在onAuthStateChangedonIdTokenChanged响应中在客户端上获得的属性?

exports.createHandler = functions.auth.user().onCreate((user, context) => {
  let uid = user.uid,
      isAnonymous = ????;
});
Run Code Online (Sandbox Code Playgroud)

node.js firebase firebase-authentication google-cloud-functions

1
推荐指数
1
解决办法
244
查看次数