• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2023 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #ifndef NWEB_PROXY_CONFIG_H
17 #define NWEB_PROXY_CONFIG_H
18 
19 #include <string>
20 
21 #include "napi/native_api.h"
22 #include "napi/native_common.h"
23 #include "napi/native_node_api.h"
24 
25 #include "proxy_rule.h"
26 
27 namespace OHOS {
28 namespace NWeb {
29 class ProxyConfig {
30 public:
31     ProxyConfig() = default;
32     ~ProxyConfig() = default;
33 
34     void InsertBypassRule(const std::string& bypassRule);
35     void InsertDirectRule(int32_t proxySchemeFilter = static_cast<int32_t>(ProxySchemeFilter::MATCH_ALL_SCHEMES));
36     void InsertProxyRule(const std::string& proxyUrl, int32_t proxySchemeFilter =
37                          static_cast<int32_t>(ProxySchemeFilter::MATCH_ALL_SCHEMES));
38     void BypassHostnamesWithoutPeriod();
39     void ClearImplicitRules();
40     void EnableReverseBypass(const bool enable);
41     const std::vector<std::string>& GetBypassRules();
42     const std::vector<ProxyRule>& GetProxyRules();
43     bool IsReverseBypassEnabled();
44 
45 private:
46     std::vector<std::string> bypassRules_;
47     std::vector<ProxyRule> proxyRules_;
48     bool enbaleReverseBypass_;
49 };
50 } // namespace NWeb
51 } // namespace OHOS
52 
53 #endif  // NWEB_PROXY_CONFIG_H
54