File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -8,6 +8,7 @@ import SocketHandler from "./lib/socket";
88import RequestMiddleware from "./middlewares/request" ;
99import { RequestChannel } from "./lib/tunnel" ;
1010import { debug } from "./utils/debug" ;
11+ import { extractIdFromDomain , isValidSocketId } from './utils/domain' ;
1112
1213// Timing-safe token comparison to prevent timing attacks
1314function timingSafeEqual ( a : string , b : string ) : boolean {
@@ -31,6 +32,18 @@ app.use(express.urlencoded({ extended: true }));
3132app . use ( express . json ( ) ) ;
3233app . use ( cors ( ) ) ;
3334
35+ app . get ( '/status' , ( req , res , next ) => {
36+ const id = extractIdFromDomain ( req . hostname ) ;
37+ if ( id && isValidSocketId ( id ) ) {
38+ return next ( ) ; // tunnel subdomain — let proxy handle it
39+ }
40+ res . json ( {
41+ status : 'ok' ,
42+ uptime : process . uptime ( ) ,
43+ version : socketHandler . getVersion ( ) ,
44+ } ) ;
45+ } ) ;
46+
3447app . use ( "/" , RequestMiddleware , ( req , res ) => {
3548 const socketId : any = req . id ;
3649
Original file line number Diff line number Diff line change @@ -151,6 +151,10 @@ class SocketHandler {
151151 } ) ;
152152 }
153153
154+ public getVersion ( ) : string {
155+ return this . version ;
156+ }
157+
154158 public getTunnelByStableId ( stableTunnelId : string ) : TunnelMapping | undefined {
155159 const mapping = this . tunnelMappings . get ( stableTunnelId ) ;
156160 if ( mapping ) {
You can’t perform that action at this time.
0 commit comments