add intercept flag to connection

addon-dailer
lqqyt2423 2 years ago
parent e21274c6e9
commit 62ce93db7d

@ -80,7 +80,8 @@ var connContextKey = new(struct{})
type ConnContext struct { type ConnContext struct {
ClientConn *ClientConn `json:"clientConn"` ClientConn *ClientConn `json:"clientConn"`
ServerConn *ServerConn `json:"serverConn"` ServerConn *ServerConn `json:"serverConn"`
FlowCount uint32 `json:"-"` Intercept bool `json:"intercept"` // Indicates whether to parse HTTPS
FlowCount uint32 `json:"-"` // Number of HTTP requests made on the same connection
proxy *Proxy proxy *Proxy
pipeConn *pipeConn pipeConn *pipeConn

@ -285,9 +285,11 @@ func (proxy *Proxy) handleConnect(res http.ResponseWriter, req *http.Request) {
"host": req.Host, "host": req.Host,
}) })
shouldIntercept := proxy.shouldIntercept == nil || proxy.shouldIntercept(req.Host)
f := newFlow() f := newFlow()
f.Request = newRequest(req) f.Request = newRequest(req)
f.ConnContext = req.Context().Value(connContextKey).(*ConnContext) f.ConnContext = req.Context().Value(connContextKey).(*ConnContext)
f.ConnContext.Intercept = shouldIntercept
defer f.finish() defer f.finish()
// trigger addon event Requestheaders // trigger addon event Requestheaders
@ -297,7 +299,7 @@ func (proxy *Proxy) handleConnect(res http.ResponseWriter, req *http.Request) {
var conn net.Conn var conn net.Conn
var err error var err error
if proxy.shouldIntercept == nil || proxy.shouldIntercept(req.Host) { if shouldIntercept {
log.Debugf("begin intercept %v", req.Host) log.Debugf("begin intercept %v", req.Host)
conn, err = proxy.interceptor.dial(req) conn, err = proxy.interceptor.dial(req)
} else { } else {

@ -111,7 +111,7 @@ class App extends React.Component<IProps, IState> {
if (msg.type === MessageType.CONN) { if (msg.type === MessageType.CONN) {
const conn = msg.content as IConnection const conn = msg.content as IConnection
conn.opening = true if (conn.intercept) conn.opening = true
this.connMgr.add(msg.id, conn) this.connMgr.add(msg.id, conn)
this.setState({ flows: this.state.flows }) this.setState({ flows: this.state.flows })
} }

@ -104,13 +104,18 @@ class ViewFlow extends React.Component<Iprops, IState> {
{ {
!conn ? null : !conn ? null :
<> <>
<div className="header-block"> {
<p>Server Connection</p> !conn.serverConn ? null :
<div className="header-block-content"> <>
<p>Address: {conn.serverConn.address}</p> <div className="header-block">
<p>Resolved Address: {conn.serverConn.peername}</p> <p>Server Connection</p>
</div> <div className="header-block-content">
</div> <p>Address: {conn.serverConn.address}</p>
<p>Resolved Address: {conn.serverConn.peername}</p>
</div>
</div>
</>
}
<div className="header-block"> <div className="header-block">
<p>Client Connection</p> <p>Client Connection</p>
<div className="header-block-content"> <div className="header-block-content">
@ -121,7 +126,11 @@ class ViewFlow extends React.Component<Iprops, IState> {
<p>Connection Info</p> <p>Connection Info</p>
<div className="header-block-content"> <div className="header-block-content">
<p>Id: {conn.clientConn.id}</p> <p>Id: {conn.clientConn.id}</p>
<p>Opening: {conn.opening ? 'true' : 'false'}</p> <p>Intercept: {conn.intercept ? 'true' : 'false'}</p>
{
conn.opening == null ? null :
<p>Opening: {conn.opening ? 'true' : 'false'}</p>
}
{ {
conn.flowCount == null ? null : conn.flowCount == null ? null :
<p>Flow Count: {conn.flowCount}</p> <p>Flow Count: {conn.flowCount}</p>

@ -4,12 +4,13 @@ export interface IConnection {
tls: boolean tls: boolean
address: string address: string
} }
serverConn: { serverConn?: {
id: string id: string
address: string address: string
peername: string peername: string
} }
opening: boolean intercept: boolean
opening?: boolean
flowCount?: number flowCount?: number
} }

Loading…
Cancel
Save