Called by ATS as our initialization point
| 102 | |
| 103 | // Called by ATS as our initialization point |
| 104 | void |
| 105 | TSPluginInit(int argc, const char *argv[]) |
| 106 | { |
| 107 | bool success = false; |
| 108 | TSCont cb_pa = nullptr; // pre-accept callback continuation |
| 109 | |
| 110 | TSPluginRegistrationInfo info; |
| 111 | info.plugin_name = PLUGIN_NAME; |
| 112 | info.vendor_name = "Apache Software Foundation"; |
| 113 | info.support_email = "dev@trafficserver.apache.org"; |
| 114 | |
| 115 | if (argc < 2) { |
| 116 | TSError(PCP "Usage: ssl_preaccept.so <ip or network>"); |
| 117 | return; |
| 118 | } |
| 119 | |
| 120 | IpRange ipRange; |
| 121 | Parse_Addr_String(std::string_view(argv[1]), ipRange); |
| 122 | ClientBlindTunnelIp.push_back(ipRange); |
| 123 | |
| 124 | if (TS_SUCCESS != TSPluginRegister(&info)) { |
| 125 | TSError(PCP "registration failed"); |
| 126 | } else if (TSTrafficServerVersionGetMajor() < 2) { |
| 127 | TSError(PCP "requires Traffic Server 2.0 or later"); |
| 128 | } else if (nullptr == (cb_pa = TSContCreate(&CB_Pre_Accept, TSMutexCreate()))) { |
| 129 | TSError(PCP "Failed to pre-accept callback"); |
| 130 | } else { |
| 131 | TSHttpHookAdd(TS_VCONN_START_HOOK, cb_pa); |
| 132 | success = true; |
| 133 | } |
| 134 | |
| 135 | if (!success) { |
| 136 | TSError(PCP "not initialized"); |
| 137 | } |
| 138 | Dbg(dbg_ctl, "Plugin %s", success ? "online" : "offline"); |
| 139 | |
| 140 | return; |
| 141 | } |
nothing calls this directly
no test coverage detected