allow port in remote client

This commit is contained in:
AJ ONeal 2018-10-15 21:30:29 -06:00
부모 a6e4bda317
커밋 0bdaacb8aa
1개의 변경된 파일12개의 추가작업 그리고 4개의 파일을 삭제

파일 보기

@ -79,11 +79,19 @@ module.exports.create = function (state) {
url += ('?_body=' + encodeURIComponent(json));
}
var method = opts.method || (args && 'POST') || 'GET';
var req = http.request({
socketPath: state._ipc.path
, method: method
var reqOpts = {
method: method
, path: url
}, function (resp) {
};
var fs = require('fs');
var portFile = path.join(path.dirname(state._ipc.path), 'telebit.port');
if (fs.existsSync(portFile)) {
reqOpts.host = 'localhost';
reqOpts.port = parseInt(fs.readFileSync(portFile, 'utf8').trim(), 10);
} else {
reqOpts.socketPath = state._ipc.path;
}
var req = http.request(reqOpts, function (resp) {
makeResponder(service, resp, fn);
});