FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
cloudflared/tunneldns/https_proxy.go at master · 4cecoder/cloudflared · GitHub
4cecoder
/
cloudflared
Public
forked from
cloudflare/cloudflared
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
cloudflared
/
tunneldns
/
https_proxy.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
39 lines (31 loc) · 993 Bytes
Breadcrumbs
cloudflared
/
tunneldns
/
https_proxy.go
Copy path
File metadata and controls
39 lines (31 loc) · 993 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package
tunneldns
import
(
"context"
"github.com/coredns/coredns/plugin"
"github.com/miekg/dns"
"github.com/pkg/errors"
)
// Upstream is a simplified interface for proxy destination
type
Upstream
interface
{
Exchange
(
ctx
context.
Context
,
query
*
dns.
Msg
) (
*
dns.
Msg
,
error
)
}
// ProxyPlugin is a simplified DNS proxy using a generic upstream interface
type
ProxyPlugin
struct
{
Upstreams
[]
Upstream
Next
plugin.
Handler
}
// ServeDNS implements interface for CoreDNS plugin
func
(
p
ProxyPlugin
)
ServeDNS
(
ctx
context.
Context
,
w
dns.
ResponseWriter
,
r
*
dns.
Msg
) (
int
,
error
) {
var
reply
*
dns.
Msg
var
backendErr
error
for
_
,
upstream
:=
range
p
.
Upstreams
{
reply
,
backendErr
=
upstream
.
Exchange
(
ctx
,
r
)
if
backendErr
==
nil
{
w
.
WriteMsg
(
reply
)
return
0
,
nil
}
}
return
dns
.
RcodeServerFailure
,
errors
.
Wrap
(
backendErr
,
"failed to contact any of the upstreams"
)
}
// Name implements interface for CoreDNS plugin
func
(
p
ProxyPlugin
)
Name
()
string
{
return
"proxy"
}
Back
|
FazBrowse Home
|
New Git URL