license "use strict" ; "require fs" ; "require network" ; "require uci" ; return L . Class . extend ( { getLocalIPs : function ( ) : Promise < string [ ] > { return network . getNetworks ( ) . then ( function ( networks ) { const localIPs = [ "127.0.0.1" , "0.0.0.0" , "::" ] ; for ( const n of networks ) { let IPv4 = n . getIPAddr ( ) ; let IPv6 = n . getIP6Addr ( ) ; if ( IPv4 && ( IPv4 = IPv4 . split ( "/" ) [ 0 ] ) && localIPs . indexOf ( IPv4 ) < 0 ) { localIPs . push ( IPv4 ) ; } if ( IPv6 && ( IPv6 = IPv6 . split ( "/" ) [ 0 ] ) && localIPs . indexOf ( IPv6 ) < 0 ) { localIPs . push ( IPv6 ) ; } } return localIPs . sort ( ) ; } ) ; } , getSections : function ( type , captionKey = "alias" ) : Promise < SectionItem [ ] > { return uci . load ( "v2ray" ) . then ( function ( ) { const sections = [ ] ; uci . sections ( "v2ray" , type , function ( s ) { let caption ; if ( ( caption = s [ captionKey ] ) ) { sections . push ( { caption : caption , value : s [ ".name" ] , } ) ; } } ) ; return sections ; } ) ; } , getDokodemoDoorPorts : function ( ) : Promise < SectionItem [ ] > { return uci . load ( "v2ray" ) . then ( function ( ) { const sections = [ ] ; uci . sections ( "v2ray" , "inbound" , function ( s ) { let port ; if ( s [ "protocol" ] == "dokodemo-door" && ( port = s [ "port" ] ) ) { let alias ; if ( ( alias = s [ "alias" ] ) ) { sections . push ( { caption : "%s - %s" . format ( alias , port ) , value : port , } ) ; } else { sections . push ( { caption : "%s:%s" . format ( s [ "listen" ] , port ) , value : port , } ) ; } } } ) ; return sections ; } ) ; } , } ) ;