Skip to content

Commit

Permalink
feat: Options variable
Browse files Browse the repository at this point in the history
  • Loading branch information
mkg20001 committed Aug 2, 2018
1 parent ddeca20 commit 31aa4cf
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 2 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
# teletunnel-protocols

Protocol definitions and matchers for the teletunnel protocol

## API

`Protocols(options)`:

`options` are the individual per-protocol options that are needed for some protos to work

This object can also be used to disable protos by setting the proto name to false

- `ssl`:
- `SNICallback`: Docs [ » TLS.createServer ](https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener)
14 changes: 13 additions & 1 deletion src/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,17 @@
'use strict'

module.exports = [
const Protos = () => [
require('./tcp')
]

function iterate (protos, options) {
return protos.filter(proto => options[proto.name] || typeof options[proto.name] === 'undefined').map(proto => {
proto.options = options[proto.name] || {}
if (proto.children) {
proto.children = iterate(proto.children, options)
}
return proto
})
}

module.exports = (options) => iterate(Protos(), options || {})
3 changes: 2 additions & 1 deletion src/tcp-protos/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
'use strict'

module.exports = [
require('./ssh')
require('./ssh'),
require('./ssl')
]
17 changes: 17 additions & 0 deletions src/tcp-protos/ssl.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
'use strict'

/* const SSL = */ module.exports = {
name: 'ssl',
properties: {
hostname: {
type: 'string',
matcher: 'glob'
}
},
detect: async (conn) => {

},
stream: async (conn) => {
// SSL.options.SNICallback
}
}

0 comments on commit 31aa4cf

Please sign in to comment.