• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #pragma once
18 
19 #include <string>
20 
21 #include <netdutils/InternetAddresses.h>
22 
23 #include "PrivateDnsCommon.h"
24 
25 namespace android::net {
26 
27 class IPrivateDnsServer {
28   public:
~IPrivateDnsServer()29     virtual ~IPrivateDnsServer(){};
30 
31     virtual PrivateDnsTransport transport() const = 0;
isDot()32     bool isDot() const { return transport() == PrivateDnsTransport::kDot; }
isDoh()33     bool isDoh() const { return transport() == PrivateDnsTransport::kDoh; }
34 
35     // Returns the provider name of the server.
36     virtual std::string provider() const = 0;
37 
38     // Returns the IP address of the server.
39     virtual netdutils::IPSockAddr addr() const = 0;
40 
41     // Returns the socket mark used for probe.
42     virtual uint32_t validationMark() const = 0;
43 
44     // Sets the validation state.
45     virtual void setValidationState(Validation val) = 0;
46 
47     // Returns the validation state.
48     virtual Validation validationState() const = 0;
49 
50     // Checks the server supports private DNS.
51     virtual bool probe() = 0;
52 
53     // Sets if the server should be active.
54     virtual void setActive(bool val) = 0;
55 
56     // Returns if the server is active.
57     virtual bool active() const = 0;
58 };
59 
60 }  // namespace android::net
61