Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
B
baas-ide
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
JIRA
JIRA
Merge Requests
1
Merge Requests
1
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
guxukai
baas-ide
Commits
23b0e3fb
Commit
23b0e3fb
authored
Oct 01, 2018
by
yann300
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
reqiure to specify the remix IDE instance to connect to
parent
a0823a3e
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
15 additions
and
8 deletions
+15
-8
remixd
bin/remixd
+7
-1
router.js
src/router.js
+3
-2
websocket.js
src/websocket.js
+5
-5
No files found.
bin/remixd
View file @
23b0e3fb
...
...
@@ -9,6 +9,7 @@ var fs = require('fs-extra')
program
.
usage
(
'-s <shared folder>'
)
.
description
(
'Provide a two ways connection between the local computer and Remix IDE'
)
.
option
(
'--remix-ide <url>'
,
'URL of remix instance allowed to connect to this web sockect connection'
)
.
option
(
'-s, --shared-folder <path>'
,
'Folder to share with Remix IDE'
)
.
option
(
'-m, --mist'
,
'start mist'
)
.
option
(
'-g, --geth'
,
'start geth'
)
...
...
@@ -25,6 +26,11 @@ program.outputHelp()
var
killCallBack
=
[]
if
(
!
program
.
remixIde
)
{
return
console
.
log
(
'
\
x1b[31m%s
\
x1b[0m'
,
'[ERR] URL Remix IDE instance has to be provided.'
)
}
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
'[WARN] You may now only use IDE at '
+
program
.
remixIde
+
' to connect to that instance'
)
if
(
program
.
devPath
)
{
if
(
fs
.
existsSync
(
program
.
devPath
))
{
killCallBack
.
push
(
startmistGeth
(
program
.
devPath
,
program
.
mist
,
program
.
geth
,
program
.
autoMine
,
program
.
rpc
,
program
.
rpcPort
))
...
...
@@ -45,7 +51,7 @@ if (program.frontend) {
if
(
program
.
sharedFolder
)
{
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
'[WARN] Any application that runs on your computer can potentially read from and write to all files in the directory.'
)
console
.
log
(
'
\
x1b[33m%s
\
x1b[0m'
,
'[WARN] Symbolinc links are not forwarded to Remix IDE
\
n'
)
var
sharedFolderrouter
=
new
Router
(
65520
,
servicesList
[
'sharedfolder'
],
(
webSocket
)
=>
{
var
sharedFolderrouter
=
new
Router
(
65520
,
servicesList
[
'sharedfolder'
],
{
remixIdeUrl
:
program
.
remixIde
},
(
webSocket
)
=>
{
servicesList
[
'sharedfolder'
].
setWebSocket
(
webSocket
)
servicesList
[
'sharedfolder'
].
setupNotifications
(
program
.
sharedFolder
)
servicesList
[
'sharedfolder'
].
sharedFolder
(
program
.
sharedFolder
)
...
...
src/router.js
View file @
23b0e3fb
var
Websocket
=
require
(
'./websocket'
)
class
Router
{
constructor
(
port
,
service
,
initCallback
)
{
constructor
(
port
,
service
,
opt
,
initCallback
)
{
this
.
opt
=
opt
this
.
port
=
port
this
.
service
=
service
this
.
initCallback
=
initCallback
}
start
()
{
var
websocket
=
new
Websocket
(
this
.
port
)
var
websocket
=
new
Websocket
(
this
.
port
,
this
.
opt
)
this
.
websocket
=
websocket
this
.
websocket
.
start
((
message
)
=>
{
this
.
call
(
message
.
id
,
message
.
service
,
message
.
fn
,
message
.
args
)
...
...
src/websocket.js
View file @
23b0e3fb
...
...
@@ -3,9 +3,10 @@ var WebSocketServer = require('websocket').server
var
http
=
require
(
'http'
)
class
WebSocket
{
constructor
(
port
)
{
constructor
(
port
,
opt
)
{
this
.
connection
=
null
this
.
port
=
port
this
.
opt
=
opt
}
start
(
callback
)
{
...
...
@@ -25,7 +26,7 @@ class WebSocket {
})
this
.
wsServer
.
on
(
'request'
,
(
request
)
=>
{
if
(
!
originIsAllowed
(
request
.
origin
))
{
if
(
!
originIsAllowed
(
request
.
origin
,
this
))
{
request
.
reject
()
console
.
log
((
new
Date
())
+
' Connection from origin '
+
request
.
origin
+
' rejected.'
)
return
...
...
@@ -67,9 +68,8 @@ class WebSocket {
}
}
function
originIsAllowed
(
origin
)
{
console
.
log
(
'origin'
,
origin
)
return
true
function
originIsAllowed
(
origin
,
self
)
{
return
origin
===
self
.
opt
.
remixIdeUrl
}
module
.
exports
=
WebSocket
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment