@@ -52,66 +52,63 @@ wss.on("connection", (ws: WebSocket, request: http.IncomingMessage) => {
5252 ssh
5353 . on ( "ready" , ( ) => {
5454 console . log ( "[ws/ssh]: SSH connection established" ) ;
55- ssh . shell (
56- { term : "xterm" , cols : parseInt ( cols ) , rows : parseInt ( rows ) } ,
57- ( err , stream ) => {
58- if ( err ) {
59- ws . send ( `[ws/ssh]: SSH shell error: ${ err . message } ` ) ;
60- ws . close ( ) ;
61- ssh . end ( ) ;
62- return ;
63- }
55+ ssh . shell ( { term : "xterm" , cols : parseInt ( cols ) , rows : parseInt ( rows ) } , ( err , stream ) => {
56+ if ( err ) {
57+ ws . send ( `[ws/ssh]: SSH shell error: ${ err . message } ` ) ;
58+ ws . close ( ) ;
59+ ssh . end ( ) ;
60+ return ;
61+ }
6462
65- // SSH -> WebSocket
66- stream . on ( "data" , ( data : Buffer ) => {
67- if ( ws . readyState === WebSocket . OPEN ) {
68- ws . send ( data ) ;
69- }
70- } ) ;
63+ // SSH -> WebSocket
64+ stream . on ( "data" , ( data : Buffer ) => {
65+ if ( ws . readyState === WebSocket . OPEN ) {
66+ ws . send ( data ) ;
67+ }
68+ } ) ;
7169
72- stream . on ( "close" , ( ) => {
73- console . log ( "[ws/ssh]: SSH stream closed" ) ;
74- ws . close ( ) ;
75- ssh . end ( ) ;
76- } ) ;
70+ stream . on ( "close" , ( ) => {
71+ console . log ( "[ws/ssh]: SSH stream closed" ) ;
72+ ws . close ( ) ;
73+ ssh . end ( ) ;
74+ } ) ;
7775
78- stream . stderr . on ( "data" , ( data : Buffer ) => {
79- if ( ws . readyState === WebSocket . OPEN ) {
80- ws . send ( `[ws/ssh]: SSH stderr: ${ data . toString ( ) } ` ) ;
81- }
82- } ) ;
83-
84- // WebSocket -> SSH
85- console . log ( "[ws/ssh]: Setting up WebSocket message handler" ) ;
86- ws . on ( "message" , ( msg ) => {
87- // support JSON control messages for resize
88- try {
89- const parsed = JSON . parse ( msg . toString ( ) ) ;
90- if ( parsed . type === "resize" ) {
91- const { cols, rows } = parsed ;
92- stream . setWindow ( rows , cols , cols * 8 , rows * 16 ) ; // width/height px optional
93- return ;
94- }
95- } catch ( e ) {
96- /* not JSON - treat as raw data */
76+ stream . stderr . on ( "data" , ( data : Buffer ) => {
77+ if ( ws . readyState === WebSocket . OPEN ) {
78+ ws . send ( `[ws/ssh]: SSH stderr: ${ data . toString ( ) } ` ) ;
79+ }
80+ } ) ;
81+
82+ // WebSocket -> SSH
83+ console . log ( "[ws/ssh]: Setting up WebSocket message handler" ) ;
84+ ws . on ( "message" , ( msg ) => {
85+ // support JSON control messages for resize
86+ try {
87+ const parsed = JSON . parse ( msg . toString ( ) ) ;
88+ if ( parsed . type === "resize" ) {
89+ const { cols, rows } = parsed ;
90+ stream . setWindow ( rows , cols , cols * 8 , rows * 16 ) ; // width/height px optional
91+ return ;
9792 }
93+ } catch ( e ) {
94+ /* not JSON - treat as raw data */
95+ }
9896
99- if ( stream . writable ) stream . write ( msg ) ;
100- } ) ;
101-
102- ws . on ( "close" , ( ) => {
103- console . log ( "[ws]: WebSocket closed, closing SSH stream" ) ;
104- stream . end ( ) ;
105- ssh . end ( ) ;
106- } ) ;
107-
108- ws . on ( "error" , ( ) => {
109- console . log ( "[ws]: WebSocket error, closing SSH stream" ) ;
110- stream . end ( ) ;
111- ssh . end ( ) ;
112- } ) ;
113- }
114- ) ;
97+ if ( stream . writable ) stream . write ( msg ) ;
98+ } ) ;
99+
100+ ws . on ( "close" , ( ) => {
101+ console . log ( "[ws]: WebSocket closed, closing SSH stream" ) ;
102+ stream . end ( ) ;
103+ ssh . end ( ) ;
104+ } ) ;
105+
106+ ws . on ( "error" , ( ) => {
107+ console . log ( "[ws]: WebSocket error, closing SSH stream" ) ;
108+ stream . end ( ) ;
109+ ssh . end ( ) ;
110+ } ) ;
111+ } ) ;
115112 } )
116113 . on ( "error" , ( err ) => {
117114 console . error ( "[ws/ssh]: SSH connection error:" , err ) ;
@@ -131,17 +128,14 @@ export const provider = new JsonRpcProvider(process.env.MAINNET_RPC);
131128
132129export const m3ter = new Contract (
133130 process . env . M3TER_CONTRACT_ADDRESS || "0x9C547B649475f1bE81323AefdbcF209C17961D5E" ,
134- [
135- "function publicKey(uint256) view returns (bytes32)" ,
136- "function tokenID(bytes32) view returns (uint256)" ,
137- ] ,
138- provider
131+ [ "function publicKey(uint256) view returns (bytes32)" , "function tokenID(bytes32) view returns (uint256)" ] ,
132+ provider ,
139133) ;
140134
141135export const rollup = new Contract (
142136 process . env . ROLLUP_CONTRACT_ADDRESS || "0xf8f2d4315DB5db38f3e5c45D0bCd59959c603d9b" ,
143137 [ "function nonce(uint256) external view returns (bytes6)" ] ,
144- provider
138+ provider ,
145139) ;
146140
147141export const ccipRevenueReader = new Contract (
@@ -152,11 +146,11 @@ export const ccipRevenueReader = new Contract(
152146 "function verifierCount() external view returns (uint256)" ,
153147 "function verifiers(uint256) external view returns (string, address)" ,
154148 ] ,
155- provider
149+ provider ,
156150) ;
157151
158152export const priceContext = new Contract (
159153 process . env . PRICE_CONTEXT_ADDRESS || "0xc6D5Ff8E80F4Ee511Db4bCf6a0BcEbF9f41aAA32" ,
160154 [ "function owed(uint256 tokenId) public view returns (uint256)" ] ,
161- provider
155+ provider ,
162156) ;
0 commit comments