From b15645b15179a931837b9103cfd13bc7cd9fb73f Mon Sep 17 00:00:00 2001 From: rocks Date: Sun, 29 Sep 2019 15:32:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=97=A0=E8=AE=BA=E5=A6=82=E4=BD=95=E9=83=BD?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=BC=80=E5=90=AF=E5=AE=89=E5=85=A8=E7=BB=84?= =?UTF-8?q?=E7=9A=84=E7=AB=AF=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- index.js | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/index.js b/index.js index 80d1c91..82b6fe5 100644 --- a/index.js +++ b/index.js @@ -144,27 +144,28 @@ async function main () { result = await client.request('CreateSecurityGroup', params, options) log.debug({ result }, 'CreateSecurityGroup') SecurityGroupId = result.SecurityGroupId - params = { - RegionId: ECS.RegionId, - SecurityGroupId, - IpProtocol: 'tcp', - SourceCidrIp: '0.0.0.0/0' - } - const port = config.ssr_server.port + '' - const PortRange = port.slice(0, -1) + '0/' + port.slice(0, -1) + '9' - result = await Promise.all([ - client.request('AuthorizeSecurityGroup', { ...params, IpProtocol: 'icmp', PortRange: '-1/-1' }, options), // enable ping - client.request('AuthorizeSecurityGroup', { ...params, PortRange: '22/22' }, options), - client.request('AuthorizeSecurityGroup', { ...params, PortRange: '80/80' }, options), - client.request('AuthorizeSecurityGroup', { ...params, PortRange: '443/443' }, options), - client.request('AuthorizeSecurityGroup', { ...params, PortRange }, options) - ]) - log.debug({ result }, 'AuthorizeSecurityGroup') } else { SecurityGroupId = result.SecurityGroups.SecurityGroup[0].SecurityGroupId VpcId = result.SecurityGroups.SecurityGroup[0].VpcId } log.info(`VpcId: ${VpcId}, SecurityGroupId: ${SecurityGroupId}`) + params = { + RegionId: ECS.RegionId, + SecurityGroupId, + IpProtocol: 'tcp', + SourceCidrIp: '0.0.0.0/0' + } + const port = config.ssr_server.port + '' + const PortRange = port.slice(0, -1) + '0/' + port.slice(0, -1) + '9' + result = await Promise.all([ + client.request('AuthorizeSecurityGroup', { ...params, IpProtocol: 'icmp', PortRange: '-1/-1' }, options), // enable ping + client.request('AuthorizeSecurityGroup', { ...params, PortRange: '22/22' }, options), + client.request('AuthorizeSecurityGroup', { ...params, PortRange: '80/80' }, options), + client.request('AuthorizeSecurityGroup', { ...params, PortRange: '443/443' }, options), + client.request('AuthorizeSecurityGroup', { ...params, PortRange }, options) + ]) + log.debug({ result }, 'AuthorizeSecurityGroup') + log.info(`为安全组${SecurityGroupId}开启端口`) let VSwitchId params = { RegionId: ECS.RegionId, VpcId, ZoneId }