pond: Connect stuff in ConnMgr
This commit is contained in:
parent
7cc6d7f8cf
commit
6f80ff0800
@ -20,6 +20,13 @@ func (h *Handler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
||||
ctx := r.Context()
|
||||
|
||||
token := r.Header.Get("Authorization")
|
||||
if token == "" {
|
||||
token = r.FormValue("token")
|
||||
if token != "" {
|
||||
token = "Bearer " + token
|
||||
}
|
||||
}
|
||||
|
||||
if token != "" {
|
||||
if !strings.HasPrefix(token, "Bearer ") {
|
||||
log.Warn("missing Bearer prefix in auth header")
|
||||
|
@ -8,9 +8,15 @@ class ConnMgr extends React.Component {
|
||||
this.connect = this.connect.bind(this)
|
||||
}
|
||||
|
||||
connect(action, from, to) {
|
||||
async connect(action, from, to) {
|
||||
if (action) {
|
||||
console.log("conn", from, to)
|
||||
const fromNd = this.props.nodes[from]
|
||||
const toNd = this.props.nodes[to]
|
||||
|
||||
const toPeerInfo = await toNd.conn.call('Filecoin.NetAddrsListen', [])
|
||||
|
||||
console.log("conn")
|
||||
await fromNd.conn.call('Filecoin.NetConnect', [toPeerInfo])
|
||||
}
|
||||
}
|
||||
|
||||
@ -18,16 +24,9 @@ class ConnMgr extends React.Component {
|
||||
const nodes = this.props.nodes
|
||||
let keys = Object.keys(nodes)
|
||||
|
||||
// T O - -
|
||||
// F
|
||||
// R
|
||||
// O
|
||||
// M
|
||||
//
|
||||
|
||||
const rows = keys.filter((_, i) => i > 0).map((k, i) => {
|
||||
const cols = keys.filter((_, j) => i >= j).map((kt, i) => {
|
||||
return (<td><input type="checkbox" onChange={e => this.connect(e.target.checked, k, kt)}/></td>)
|
||||
return (<td><input key={k + "-" + kt} type="checkbox" onChange={e => this.connect(e.target.checked, k, kt)}/></td>)
|
||||
})
|
||||
return (
|
||||
<tr><td>{k}</td>{cols}</tr>
|
||||
|
@ -30,7 +30,7 @@ class FullNode extends React.Component {
|
||||
token: token,
|
||||
}))
|
||||
|
||||
const client = new Client(`ws://127.0.0.1:${this.props.node.ApiPort}/rpc/v0`)
|
||||
const client = new Client(`ws://127.0.0.1:${this.props.node.ApiPort}/rpc/v0?token=${token}`)
|
||||
client.on('open', () => {
|
||||
this.setState(() => ({
|
||||
state: stateConnected,
|
||||
|
Loading…
Reference in New Issue
Block a user