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的每一个API都想暴露出来,disabled_endpoints里面就是不能访问的API。

 

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

 

 

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

 

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

 

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

 

  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. }

 

Mesos源码分析(3): Mesos Master的启动之二的更多相关文章

  1. Mesos源码分析(5): Mesos Master的启动之四

      5. Create an instance of allocator.   代码如下   Mesos源码中默认的Allocator,即HierarchicalDRFAllocator的位置在$ME ...

  2. Mesos源码分析(4) Mesos Master的启动之三

    3. ModuleManager::load(flags.modules.get())如果有参数--modules或者--modules_dir=dirpath,则会将路径中的so文件load进来   ...

  3. Mesos源码分析(2): Mesos Master的启动之一

    Mesos Master的启动参数如下: /usr/sbin/mesos-master --zk=zk://127.0.0.1:2181/mesos --port=5050 --log_dir=/va ...

  4. Mesos源码分析(6): Mesos Master的初始化

      Mesos Master的初始化在src/master/master.cpp中     在Mesos Master的log中,是能看到这一行的.   1.初始化role,并设置weight权重   ...

  5. Mesos源码分析(1): Mesos的启动过程总论

  6. Mesos源码分析(9): Test Framework的启动

    我们以Test Framework为例子解释Framework的启动方式. Test Framework的代码在src/examples/test_framework.cpp中的main函数 首先要指 ...

  7. Tomcat源码分析 (七)----- Tomcat 启动过程(二)

    在上一篇文章中,我们分析了tomcat的初始化过程,是由Bootstrap反射调用Catalina的load方法完成tomcat的初始化,包括server.xml的解析.实例化各大组件.初始化组件等逻 ...

  8. Mesos源码分析

    Mesos源码分析(1): Mesos的启动过程总论 Mesos源码分析(2): Mesos Master的启动之一 Mesos源码分析(3): Mesos Master的启动之二 Mesos源码分析 ...

  9. Mesos源码分析(11): Mesos-Master接收到launchTasks消息

    根据Mesos源码分析(6): Mesos Master的初始化中的代码分析,当Mesos-Master接收到launchTask消息的时候,会调用Master::launchTasks函数.   v ...

随机推荐

  1. R语言数据类型

    R语言数据类型[转!!]Zhao-Pace  https://www.cnblogs.com/zhao441354231/p/5970544.html   R语言用来存储数据的对象包括: 向量, 因子 ...

  2. MySQL时区错误导致server time zone value 'Öйú±ê׼ʱ¼ä' 错误

    时区错误 由于中国是东八区,跟mysql配置不同,需要修改: 管理员登录MySQL OK成功

  3. Google Python命名规范

    Google Python命名规范 module_name,  模块 package_name,  包 ClassName,  类 method_name,  方法 ExceptionName,    ...

  4. jsp多模块相同数据提交到后台之数据处理

    最近在写一个java多模块表单提交,起初想的只是一个简单的form表单提交,写的时候发现不是真简单.多个相同类型数据提交到后台接收的问题很困难. 于是,和人进行深入的讨论,感觉j以json的格式提交时 ...

  5. javascript--实现几个简单的操作

    利用JS实现几个简单的功能 --还有省市联动,商品的左右选择,表单的校验.但在学了jQuery之后,感觉这个没那么重要了,就不写了 表格的全选和全不选 表格的动态隔行换色 <!DOCTYPE h ...

  6. ZOJ Problem Set - 3593 拓展欧几里得 数学

    ZOJ Problem Set - 3593 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=3593 One Person ...

  7. Moq 在.net Core 单元测试中的使用

    Moq,主要用来伪造接口的实现类,实现方法,属性 moq The most popular and friendly mocking framework for .NET What? Moq (pro ...

  8. HeadFirst学习笔记-2.观察者(Observer)模式

    认识观察者模式 我们用报纸和杂志的订阅为例来介绍: 报社的业务就是出版报纸. 向某家报社订阅报纸,只要他们有新报纸出版,就会给你送来.只要你是他们的订户,你就会一直收到新报纸. 当你不想再看报纸的时候 ...

  9. *CTF 2019 quicksort、babyshell、upxofcpp

    这次参加比赛总共出了三道,有两道队友都先交了,还是tcl,heap_master卡了差不多一天没解决....还是记录一下出的题目吧 quicksort 题目大体流程就是输入要输入的数字数量,然后输入数 ...

  10. SpringBoot与日志框架1(基本使用)

    一.日志框架 1.无论在什么系统,日志框架都是一个重要角色,所以理解和用好日志框架是相当重要的:像JDBC一样,日志框架分为接口层的门面和具体的实现组成. 2.市面上的产品: 2.1门面:SLF4J( ...