File tree 3 files changed +64
-0
lines changed
3 files changed +64
-0
lines changed Original file line number Diff line number Diff line change @@ -93,3 +93,6 @@ rpc-check: rpc
93
93
94
94
rpc-stubs :
95
95
cd cmd/wasm-client; ./gen_stubs.sh
96
+
97
+ example-server :
98
+ go run example-server.go example/ 8080
Original file line number Diff line number Diff line change 1
1
# terminal-connect
2
2
Placeholder repository for everything that is needed for Terminal Connect.
3
+
4
+ ## Run the example WASM application
5
+
6
+ ### Prerequisites
7
+
8
+ 1 . Install and run ` aperture ` from the
9
+ [ ` mailbox ` branch of the internal repo] ( https://github.com/lightninglabs/aperture-mailbox/tree/mailbox ) .
10
+ We assume ` aperture ` is running with TLS on ` localhost:11110 ` .
11
+
12
+ ### Run lnd
13
+
14
+ 1 . Compile and run ` lnd ` from the [ ` mailbox ` branch of the internal repo] ( https://github.com/lightninglabs/lnd-mailbox/tree/mailbox ) .
15
+ 2 . Run ` lnd connectmailbox localhost:11110 --dev_server ` , copy the password for
16
+ later use. You'll need to run this command again to generate a new password
17
+ for each new connection attempt. At the moment re-using the same password
18
+ across multiple runs of the WASM client doesn't work cleanly.
19
+
20
+ ### Compile and run the example
21
+
22
+ 1 . In this repo, run ` make wasm ` to compile the example client to WASM.
23
+ 2 . Run ` make example-server ` to start the example HTTP server.
24
+ 3 . Open [ https://localhost:11110 ] ( https://localhost:11110 ) and make sure you
25
+ add an exception for ` aperture ` 's TLS certificate! This might not work in
26
+ Chrome. This step is crucial, without it the connection from the example app
27
+ to ` aperture ` will fail.
28
+ 3 . Visit [ http://localhost:8080 ] ( http://localhost:8080 ) to see the example
29
+ client in action. It is recommended to open the browser console (F12) to see
30
+ the console logs.
Original file line number Diff line number Diff line change
1
+ package main
2
+
3
+ import (
4
+ "log"
5
+ "net/http"
6
+ "os"
7
+ "strings"
8
+ )
9
+
10
+ func main () {
11
+ if len (os .Args ) != 3 {
12
+ log .Fatal ("Not enough arguments provided. Please provide the " +
13
+ "file serving directory and the port." )
14
+ }
15
+ dir := os .Args [1 ]
16
+ port := os .Args [2 ]
17
+ fs := http .FileServer (http .Dir (dir ))
18
+ log .Print ("Serving " + dir + " on http://localhost:" + port )
19
+ err := http .ListenAndServe (":" + port , http .HandlerFunc (
20
+ func (resp http.ResponseWriter , req * http.Request ) {
21
+ log .Println (req .URL )
22
+ resp .Header ().Add ("Cache-Control" , "no-cache" )
23
+ if strings .HasSuffix (req .URL .Path , ".wasm" ) {
24
+ resp .Header ().Set ("content-type" , "application/wasm" )
25
+ }
26
+ resp .Header ().Set ("Access-Control-Allow-Origin" , "*" )
27
+ fs .ServeHTTP (resp , req )
28
+ },
29
+ ))
30
+ if err != nil {
31
+ log .Fatalf ("Error running server: %v" , err )
32
+ }
33
+ }
You can’t perform that action at this time.
0 commit comments