您正在查看: Surou 发布的文章

WSL中设置DNS

由于公司gitlab搬到了vpn内,虽然Windows运行了Vpn软件,并在对应的VPN网卡上设置了域DNS,但是WSL走的子系统单独的DNS,所以虽然能ping通gitlab所在服务器IP,但是无法解析gitlab对应的域名。

设置WSL子系统DNS

1. 启动WSL,进入目录,创建wsl.conf
bash
cd ~/../../etc
sudo vim wsl.conf
sudo touch wsl.conf
2. 将这些行添加到wsl.conf中
[network]
generateResolvConf=false
3. 退出WSL,关闭WSL
exit
wsl --shutdown

此时,由于有了wsl.conf,run/resolvconf应该不再存在,并且将不再被创建

4. 删除现有的符号链接文件
cd ~/../../etc
sudo rm resolv.conf
5. 创建一个新的resolv.conf
sudo vim resolv.conf
sudo touch resolv.conf
将自己的DNS,添加到resolv.conf
nameserver 8.8.8.8 // 用您喜欢的功能名称服务器替换8.8.8.8。
重启WSL
exit
wsl --shutdown
再次启动WSL
bash

此时WSL解析内网域名就OK了

参考

https://github.com/microsoft/WSL/issues/5256#issuecomment-666545999

eos 链改 2.0.x 升级2.1.x的修改点

  1. eosio::name 声明变量的N() 取消了,统一用 ""_n
  2. fc::optional替换成 std::optional
  3. t->packed_trx()->get_signed_transaction() 改成v0 获取,修改为
    t->packed_trx()->to_packed_transaction_v0()->get_signed_transaction()
  4. mongo_db_plugin 相关被删除,包括mongo异常信息类型
  5. bs->block->id(); 使用V0
    bs->block->to_signed_block_v0()->id();

持续总结

dfuse-eosio 常用GraphQL API接口整理

测试例子

https://github.com/dfuse-io/docs/tree/master/quickstarts

@ dfuse/client使用例子

global.fetch = require('node-fetch');
global.WebSocket = require('ws');

// CODE:BEGIN:quickstarts_javascript_node_eos_section1
const { createDfuseClient } = require('@dfuse/client');

const client = createDfuseClient({
  network: '39.106.103.152:8080',
  authentication: false,
  secure: false,
});
// CODE:END:quickstarts_javascript_node_eos_section1
// CODE:BEGIN:quickstarts_javascript_node_eos_section2
// You must use a `$cursor` variable so stream starts back at last marked cursor on reconnect!
const operation = `subscription($cursor: String!) {
  searchTransactionsForward(query:"receiver:eosio.token action:transfer -data.quantity:'0.0001 EOS'", cursor: $cursor) {
    undo cursor
    trace { id matchingActions { json } }
  }
}`;
// CODE:END:quickstarts_javascript_node_eos_section2
// CODE:BEGIN:quickstarts_javascript_node_eos_section3
async function main() {
  const stream = await client.graphql(operation, message => {
    if (message.type === 'data') {
      const {
        undo,
        cursor,
        trace: { id, matchingActions }
      } = message.data.searchTransactionsForward;
      matchingActions.forEach(({ json: { from, to, quantity } }) => {
        console.log(
          `Transfer ${from} -> ${to} [${quantity}]${undo ? ' REVERTED' : ''}`
        );
      });

      // Mark stream at cursor location, on re-connect, we will start back at cursor
      stream.mark({ cursor });
    }

    if (message.type === 'error') {
      console.log('An error occurred', message.errors, message.terminal);
    }

    if (message.type === 'complete') {
      console.log('Completed');
    }
  });

  // Waits until the stream completes, or forever
  await stream.join();
  await client.release();
}
// CODE:END:quickstarts_javascript_node_eos_section3
// CODE:BEGIN:quickstarts_javascript_node_eos_section4
main().catch(error => console.log('Unexpected error', error));
// CODE:END:quickstarts_javascript_node_eos_section4

接口文档

https://docs.dfuse.io/eosio/public-apis/reference/graphql-api/

常用接口整理

稍后补充

GraphQL 与 REST 相比的优势和短板

https://zhuanlan.zhihu.com/p/95521039

dfuse/client 如何配置访问权限

如何在我自己构建和运行的@dfuse/client中配置apiKey
由于dfuse官方权限这块并没有开源,可以先把权限相关关闭
可以只用测试例子演示

const client = createDfuseClient({
  network: '39.106.103.152:8080',
  authentication: false,
  secure: false,
});

参考

https://github.com/dfuse-io/dfuse-eosio/issues/206

https://github.com/dfuse-io/client-js/blob/e86735957d348ced88f141720979dec8516db5ef/examples/basic/dfuse-for-eosio.ts#L13

如何让dfuse-eosio 的dashboard 可以外网访问

由于部署的服务器一般为server版,没有UI界面,所以目前dfuse-eosio默认的本地访问地址很不方便,为了外部访问,编译前,需要修改下配置,

要修改的配置在https://github.com/dfuse-io/dlauncher 项目中,当编译dfuse-eosio时,./scripts/build.sh会自动在当前目录的上层目录下,获取dlauncher源码。

当dlauncher代码获取完,再将dlauncher\dashboard\client\src\.env中的 http://localhost:8080修改成对应的地址

REACT_APP_DASHBOARD_GRPC_WEB_URL=http://localhost:8080/api

比如修改成

REACT_APP_DASHBOARD_GRPC_WEB_URL=http://39.106.103.152:8080/api

然后重新编译即可。

当然我们只是为了测试演示,生产环境中,并不会直接暴露在外网,因为此后台并没有权限验证,一般是外层再加层防护,比如VPN