yakuza0 2.21.6-beta.7 → 2.21.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yakuza0",
3
- "version": "2.21.6-beta.7",
3
+ "version": "2.21.6",
4
4
  "description": "yakuza0 with nuxt",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -269,8 +269,9 @@ exports.default = function () {
269
269
  // })
270
270
  // }
271
271
  }
272
-
273
- proxyReq.setHeader('host', proxyReq.host);
272
+ if (!_config2.default.security.isStupid) {
273
+ proxyReq.setHeader('host', proxyReq.host);
274
+ }
274
275
  }
275
276
  });
276
277
 
@@ -354,7 +355,7 @@ exports.default = function () {
354
355
  nuxtAppName: config.appName,
355
356
  nuxtAppConf: config.appConf || {}
356
357
  };
357
- if (req.url.indexOf(_config2.default.proxyServer.ws.key) !== -1) {
358
+ if (req.url.startsWith('/' + _config2.default.proxyServer.ws.key)) {
358
359
  var headers = {
359
360
  Host: _config2.default.server.orbHost
360
361
  };
@@ -53,8 +53,10 @@ export default async (ctx, inject) => {
53
53
 
54
54
  const body = {
55
55
  head, detail, level,
56
- sourceName: yConf.server.log.prefixSourceName + ' -> ' + yConf.name + (yConf.server.log.sourceName ? ' -> ' + yConf.server.log.sourceName : ''),
57
- streamName: ' -> ' + $yk.appName + (yConf.server.log.streamName ? ' -> ' + yConf.server.log.streamName : ''),
56
+ // sourceName: yConf.server.log.prefixSourceName + ' -> ' + yConf.name + (yConf.server.log.sourceName ? ' -> ' + yConf.server.log.sourceName : ''),
57
+ // streamName: ' -> ' + yConf.name + ' -> ' + $yk.appName + (yConf.server.log.streamName ? ' -> ' + yConf.server.log.streamName : ''),
58
+ sourceName: '',
59
+ streamName: ' -> ' + (yConf.server.log.sourceName ? ' -> ' + yConf.server.log.sourceName : '') + yConf.name + ' -> ' + $yk.appName + (yConf.server.log.streamName ? ' -> ' + yConf.server.log.streamName : ''),
58
60
  }
59
61
 
60
62
  if (yConf.server.log.levels[level] >= nowLv) {
@@ -65,16 +67,16 @@ export default async (ctx, inject) => {
65
67
 
66
68
  if (yConf.server.log.onlySSR) {
67
69
  if (yConf.server.log.server && $utils.checkServer()) {
68
- body.sourceName += ' -> server'
70
+ body.streamName += ' -> server'
69
71
  await send(body)
70
72
  }
71
73
  } else {
72
74
  if (yConf.server.log.server && $utils.checkServer()) {
73
- body.sourceName += ' -> server'
75
+ body.streamName += ' -> server'
74
76
  await send(body)
75
77
  }
76
78
  if (yConf.server.log.client && !$utils.checkServer()) {
77
- body.sourceName += ' -> client'
79
+ body.streamName += ' -> client'
78
80
  await send(body)
79
81
  }
80
82
  }
@@ -0,0 +1,144 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ws = undefined;
7
+
8
+ var _extends2 = require('babel-runtime/helpers/extends');
9
+
10
+ var _extends3 = _interopRequireDefault(_extends2);
11
+
12
+ var _typeof2 = require('babel-runtime/helpers/typeof');
13
+
14
+ var _typeof3 = _interopRequireDefault(_typeof2);
15
+
16
+ var _classCallCheck2 = require('babel-runtime/helpers/classCallCheck');
17
+
18
+ var _classCallCheck3 = _interopRequireDefault(_classCallCheck2);
19
+
20
+ var _createClass2 = require('babel-runtime/helpers/createClass');
21
+
22
+ var _createClass3 = _interopRequireDefault(_createClass2);
23
+
24
+ var _socket = require('socket.io-client');
25
+
26
+ var _socket2 = _interopRequireDefault(_socket);
27
+
28
+ var _yakuza = require('yakuza1');
29
+
30
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
31
+
32
+ // import yConf from '../config';
33
+ var Bac = function () {
34
+ function Bac(uri, opts) {
35
+ (0, _classCallCheck3.default)(this, Bac);
36
+
37
+ if ((typeof uri === 'undefined' ? 'undefined' : (0, _typeof3.default)(uri)) === 'object') {
38
+ opts = uri;
39
+ uri = undefined;
40
+ }
41
+
42
+ this.opts = (0, _extends3.default)({
43
+ path: uri,
44
+ wsPath: 'proxy-ws-o28',
45
+ transports: ['websocket'],
46
+ key: '__ws__',
47
+ lite: true,
48
+
49
+ receive: null
50
+ }, opts);
51
+ this.listen = {
52
+ receive: []
53
+ };
54
+ this.before();
55
+ }
56
+
57
+ (0, _createClass3.default)(Bac, [{
58
+ key: 'before',
59
+ value: function before() {
60
+ var _this = this;
61
+
62
+ this.ws = {
63
+ sock: null,
64
+ receiveEv: {}
65
+ };
66
+
67
+ this.sequence();
68
+
69
+ this.ws.sock.on('connect', function () {
70
+ // if (this.opts.lite) {
71
+ // const protocol = jsUrl('protocol', yConf.proxyServer.baseURL);
72
+ // this.opts.path = `ws${yConf.proxyServer.baseURL.replace(protocol, '')}${jsUrl('path', this.opts.path)}`;
73
+ // }
74
+ _this.event = (0, _yakuza.md5)(_this.opts.path + _this.ws.sock.id);
75
+ if (typeof _this.opts.receive === 'function') {
76
+ _this.listen.receive.push(_this.opts.receive);
77
+ }
78
+ _this.init();
79
+ });
80
+ }
81
+ }, {
82
+ key: 'sequence',
83
+ value: function sequence() {
84
+ var path = '/' + this.opts.wsPath + '/pxdl';
85
+ this.ws.sock = (0, _socket2.default)(path, {
86
+ path: path,
87
+ transports: this.opts.transports
88
+ });
89
+ }
90
+ }, {
91
+ key: 'init',
92
+ value: function init() {
93
+ var _this2 = this;
94
+
95
+ if (!this.ws.receiveEv[this.event]) {
96
+ this.ws.sock.emit('init', {
97
+ path: this.opts.path,
98
+ lite: this.opts.lite
99
+ });
100
+ this.ws.receiveEv[this.event] = true;
101
+ this.ws.sock.off(this.event);
102
+ this.ws.sock.on(this.event, function (msg) {
103
+ _this2.listen.receive.forEach(function (fn) {
104
+ return fn(msg);
105
+ });
106
+ });
107
+ }
108
+ }
109
+ }, {
110
+ key: 'send',
111
+ value: function send(event, msg) {
112
+ if (msg) {
113
+ this.ws.sock.emit(event, msg);
114
+ } else {
115
+ this.ws.sock.emit(this.event, event);
116
+ }
117
+ }
118
+ }, {
119
+ key: 'receive',
120
+ value: function receive(callback) {
121
+ if (typeof callback === 'function') {
122
+ this.listen.receive.push(callback);
123
+ }
124
+ }
125
+ }, {
126
+ key: 'io',
127
+ get: function get() {
128
+ return this.ws.sock;
129
+ }
130
+ }]);
131
+ return Bac;
132
+ }();
133
+
134
+ exports.default = function (uri, opts) {
135
+ return new Bac(uri, opts);
136
+ };
137
+
138
+ var ws = exports.ws = function ws(url, opt) {
139
+ var path = '/proxy-ws-o28/api-ws' + url;
140
+ return (0, _socket2.default)('/', (0, _extends3.default)({
141
+ path: path,
142
+ transports: ['websocket']
143
+ }, opt));
144
+ };