1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
2 /* vim: set sw=2 ts=8 et tw=80 : */
3 /* This Source Code Form is subject to the terms of the Mozilla Public
4  * License, v. 2.0. If a copy of the MPL was not distributed with this
5  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
6 
7 #ifndef mozilla_net_ODoH_h
8 #define mozilla_net_ODoH_h
9 
10 #include "TRR.h"
11 
12 namespace mozilla {
13 namespace net {
14 
15 class ODoH final : public TRR {
16  public:
ODoH(AHostResolver * aResolver,nsHostRecord * aRec,enum TrrType aType)17   explicit ODoH(AHostResolver* aResolver, nsHostRecord* aRec,
18                 enum TrrType aType)
19       : TRR(aResolver, aRec, aType) {}
20   // when following CNAMEs
ODoH(AHostResolver * aResolver,nsHostRecord * aRec,nsCString & aHost,enum TrrType & aType,unsigned int aLoopCount,bool aPB)21   explicit ODoH(AHostResolver* aResolver, nsHostRecord* aRec, nsCString& aHost,
22                 enum TrrType& aType, unsigned int aLoopCount, bool aPB)
23       : TRR(aResolver, aRec, aHost, aType, aLoopCount, aPB) {}
24   NS_IMETHOD Run() override;
25   // ODoH should not support push.
GetInterface(const nsIID &,void **)26   NS_IMETHOD GetInterface(const nsIID&, void**) override {
27     return NS_ERROR_NO_INTERFACE;
28   }
29 
30  protected:
31   virtual ~ODoH() = default;
32   virtual DNSPacket* GetOrCreateDNSPacket() override;
33   virtual nsresult CreateQueryURI(nsIURI** aOutURI) override;
ContentType()34   virtual const char* ContentType() const override {
35     return "application/oblivious-dns-message";
36   }
ResolverType()37   virtual DNSResolverType ResolverType() const override {
38     return DNSResolverType::ODoH;
39   }
MaybeBlockRequest()40   virtual bool MaybeBlockRequest() override {
41     // TODO: check excluded list
42     return false;
43   };
RecordProcessingTime(nsIChannel * aChannel)44   virtual void RecordProcessingTime(nsIChannel* aChannel) override {
45     // TODO: record processing time for ODoH.
46   }
ReportStatus(nsresult aStatusCode)47   virtual void ReportStatus(nsresult aStatusCode) override {
48     // TODO: record status in ODoHService.
49   }
50   virtual void HandleTimeout() override;
51   virtual void HandleEncodeError(nsresult aStatusCode) override;
52   virtual void HandleDecodeError(nsresult aStatusCode) override;
53 };
54 
55 }  // namespace net
56 }  // namespace mozilla
57 
58 #endif
59