core,presets: switch to use SOCKET_CONNECT_TO_REMOTE
This commit is contained in:
parent
d5d8dca99a
commit
5d4bd8c3a9
@ -13,9 +13,8 @@ import {
|
||||
} from './middleware';
|
||||
|
||||
import {
|
||||
SOCKET_CONNECT_TO_DST,
|
||||
PROCESSING_FAILED,
|
||||
PROXY_HANDSHAKE_DONE
|
||||
SOCKET_CONNECT_TO_REMOTE,
|
||||
PROCESSING_FAILED
|
||||
} from '../presets/defs';
|
||||
|
||||
const TRACK_CHAR_UPLOAD = '↑';
|
||||
@ -382,8 +381,7 @@ export class Socket extends EventEmitter {
|
||||
*/
|
||||
onPipeNotified(action) {
|
||||
switch (action.type) {
|
||||
case PROXY_HANDSHAKE_DONE:
|
||||
case SOCKET_CONNECT_TO_DST: {
|
||||
case SOCKET_CONNECT_TO_REMOTE: {
|
||||
const {targetAddress, onConnected} = action.payload;
|
||||
if (__IS_SERVER__) {
|
||||
// connect to destination
|
||||
|
@ -1,4 +1,4 @@
|
||||
import {PROXY_HANDSHAKE_DONE} from '../defs';
|
||||
import {SOCKET_CONNECT_TO_REMOTE} from '../defs';
|
||||
import SsBasePreset from '../ss-base';
|
||||
|
||||
describe('SsBasePreset#clientOut', function () {
|
||||
@ -6,7 +6,7 @@ describe('SsBasePreset#clientOut', function () {
|
||||
const preset = new SsBasePreset();
|
||||
|
||||
preset.onNotified({
|
||||
type: PROXY_HANDSHAKE_DONE,
|
||||
type: SOCKET_CONNECT_TO_REMOTE,
|
||||
payload: {
|
||||
targetAddress: {
|
||||
type: 3,
|
||||
|
@ -1,5 +1,4 @@
|
||||
export const SOCKET_CONNECT_TO_DST = 'socket/connect/to/dst';
|
||||
export const PROXY_HANDSHAKE_DONE = 'socket/handshake/done';
|
||||
export const SOCKET_CONNECT_TO_REMOTE = 'socket/connect/to/remote';
|
||||
export const PROCESSING_FAILED = 'processing/failed';
|
||||
|
||||
export class IPreset {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import crypto from 'crypto';
|
||||
import {EVP_BytesToKey, numberToBuffer, hmac, Xor} from '../utils';
|
||||
import {IPreset, SOCKET_CONNECT_TO_DST, PROXY_HANDSHAKE_DONE} from './defs';
|
||||
import {IPreset, SOCKET_CONNECT_TO_REMOTE} from './defs';
|
||||
|
||||
const IV_LEN = 16;
|
||||
const HMAC_LEN = 16;
|
||||
@ -76,7 +76,7 @@ export default class ExpBaseAuthStreamPreset extends IPreset {
|
||||
}
|
||||
|
||||
onNotified(action) {
|
||||
if (__IS_CLIENT__ && action.type === PROXY_HANDSHAKE_DONE) {
|
||||
if (__IS_CLIENT__ && action.type === SOCKET_CONNECT_TO_REMOTE) {
|
||||
const {host, port} = action.payload.targetAddress;
|
||||
this._host = Buffer.from(host);
|
||||
this._port = numberToBuffer(port);
|
||||
@ -145,7 +145,7 @@ export default class ExpBaseAuthStreamPreset extends IPreset {
|
||||
|
||||
// notify to connect to the real server
|
||||
broadcast({
|
||||
type: SOCKET_CONNECT_TO_DST,
|
||||
type: SOCKET_CONNECT_TO_REMOTE,
|
||||
payload: {
|
||||
targetAddress: {
|
||||
host: addr,
|
||||
|
@ -1,7 +1,7 @@
|
||||
import net from 'net';
|
||||
import ip from 'ip';
|
||||
import {isValidHostname, numberToBuffer, hash} from '../utils';
|
||||
import {IPreset, SOCKET_CONNECT_TO_DST, PROXY_HANDSHAKE_DONE} from './defs';
|
||||
import {IPreset, SOCKET_CONNECT_TO_REMOTE} from './defs';
|
||||
|
||||
/**
|
||||
* @description
|
||||
@ -65,7 +65,7 @@ export default class ExpBaseWithPaddingPreset extends IPreset {
|
||||
}
|
||||
|
||||
onNotified(action) {
|
||||
if (__IS_CLIENT__ && action.type === PROXY_HANDSHAKE_DONE) {
|
||||
if (__IS_CLIENT__ && action.type === SOCKET_CONNECT_TO_REMOTE) {
|
||||
const {host, port} = action.payload.targetAddress;
|
||||
this._host = Buffer.from(host);
|
||||
this._port = numberToBuffer(port);
|
||||
@ -127,7 +127,7 @@ export default class ExpBaseWithPaddingPreset extends IPreset {
|
||||
|
||||
// notify to connect to the real server
|
||||
broadcast({
|
||||
type: SOCKET_CONNECT_TO_DST,
|
||||
type: SOCKET_CONNECT_TO_REMOTE,
|
||||
payload: {
|
||||
targetAddress: {
|
||||
host: addr,
|
||||
|
@ -1,6 +1,6 @@
|
||||
import ip from 'ip';
|
||||
import {isValidHostname, numberToBuffer} from '../utils';
|
||||
import {IPreset, SOCKET_CONNECT_TO_DST, PROXY_HANDSHAKE_DONE} from './defs';
|
||||
import {IPreset, SOCKET_CONNECT_TO_REMOTE} from './defs';
|
||||
|
||||
const ATYP_V4 = 0x01;
|
||||
const ATYP_V6 = 0x04;
|
||||
@ -55,7 +55,7 @@ export default class SsBasePreset extends IPreset {
|
||||
_staging = Buffer.alloc(0);
|
||||
|
||||
onNotified(action) {
|
||||
if (__IS_CLIENT__ && action.type === PROXY_HANDSHAKE_DONE) {
|
||||
if (__IS_CLIENT__ && action.type === SOCKET_CONNECT_TO_REMOTE) {
|
||||
const {type, host, port} = action.payload.targetAddress;
|
||||
this._atyp = type;
|
||||
this._port = numberToBuffer(port);
|
||||
@ -137,7 +137,7 @@ export default class SsBasePreset extends IPreset {
|
||||
|
||||
// notify to connect to the real server
|
||||
broadcast({
|
||||
type: SOCKET_CONNECT_TO_DST,
|
||||
type: SOCKET_CONNECT_TO_REMOTE,
|
||||
payload: {
|
||||
targetAddress: {
|
||||
type: atyp,
|
||||
|
Loading…
Reference in New Issue
Block a user