首页 技术 正文
技术 2022年11月19日
0 收藏 459 点赞 2,999 浏览 1548 个字

2. process::firewall::install(move(rules));如果有参数–firewall_rules则会添加规则

 

对应的代码如下:

  1. // Initialize firewall rules.
  2. if (flags.firewall_rules.isSome()) {
  3.   vector<Owned<FirewallRule>> rules;
  4.  
  5.   const Firewall firewall = flags.firewall_rules.get();
  6.  
  7.   if (firewall.has_disabled_endpoints()) {
  8.     hashset<string> paths;
  9.  
  10.     foreach (const
    string& path, firewall.disabled_endpoints().paths()) {
  11.       paths.insert(path);
  12.     }
  13.  
  14.     rules.emplace_back(new DisabledEndpointsFirewallRule(paths));
  15.   }
  16.  
  17.   process::firewall::install(move(rules));
  18. }

 

对应的命令行参数如下:

Mesos源码分析(3): Mesos Master的启动之二

 

 

这个参数的主要作用为,并不是Mesos的每一个API都想暴露出来,disabled_endpoints里面就是不能访问的API。

 

上面的install的代码会做下面的事情

Mesos源码分析(3): Mesos Master的启动之二

 

Mesos源码分析(3): Mesos Master的启动之二

 

最终会放到环境变量firewallRules里面。

 

那这些firewall是什么事情起作用的呢?

 

在3rdparty/libprocess/src/process.cpp里面有函数

Mesos源码分析(3): Mesos Master的启动之二

 

  1. synchronized (firewall_mutex) {
  2.   // Don’t use a const reference, since it cannot be guaranteed
  3.   // that the rules don’t keep an internal state.
  4.   foreach (Owned<firewall::FirewallRule>& rule, firewallRules) {
  5.     Option<Response> rejection = rule->apply(socket, *request);
  6.     if (rejection.isSome()) {
  7.       VLOG(1) << “Returning ‘”<< rejection.get().status << “‘ for ‘”
  8.               << request->url.path << “‘ (firewall rule forbids request)”;
  9.  
  10.       // TODO(arojas): Get rid of the duplicated code to return an
  11.       // error.
  12.  
  13.       // Get the HttpProxy pid for this socket.
  14.       PID<HttpProxy> proxy = socket_manager->proxy(socket);
  15.  
  16.       // Enqueue the response with the HttpProxy so that it respects
  17.       // the order of requests to account for HTTP/1.1 pipelining.
  18.       dispatch(
  19.           proxy,
  20.           &HttpProxy::enqueue,
  21.           rejection.get(),
  22.           *request);
  23.  
  24.       // Cleanup request.
  25.       delete request;
  26.       return;
  27.     }
  28.   }
  29. }

 

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,493
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,907
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,740
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,495
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:8,133
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:5,297