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 {
ClientConn *ClientConn `json:"clientConn"`
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
pipeConn *pipeConn

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

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

@ -104,13 +104,18 @@ class ViewFlow extends React.Component<Iprops, IState> {
{
!conn ? null :
<>
<div className="header-block">
<p>Server Connection</p>
<div className="header-block-content">
<p>Address: {conn.serverConn.address}</p>
<p>Resolved Address: {conn.serverConn.peername}</p>
</div>
</div>
{
!conn.serverConn ? null :
<>
<div className="header-block">
<p>Server Connection</p>
<div className="header-block-content">
<p>Address: {conn.serverConn.address}</p>
<p>Resolved Address: {conn.serverConn.peername}</p>
</div>
</div>
</>
}
<div className="header-block">
<p>Client Connection</p>
<div className="header-block-content">
@ -121,7 +126,11 @@ class ViewFlow extends React.Component<Iprops, IState> {
<p>Connection Info</p>
<div className="header-block-content">
<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 :
<p>Flow Count: {conn.flowCount}</p>

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

Loading…
Cancel
Save