Skip to content

Commit 6612576

Browse files
enhance executable check
1 parent d9778b0 commit 6612576

File tree

2 files changed

+27
-16
lines changed

2 files changed

+27
-16
lines changed

redisinsight/api/src/utils/hosting-provider-helper.spec.ts

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ const getHostingProviderTests = [
3737
hello: [
3838
'server', 'redis',
3939
],
40-
info: '#Server\r\n'
40+
info: '# Server\r\n'
4141
+ 'executable:/opt/redis/bin/redis-server',
4242
output: HostingProvider.REDIS_COMMUNITY_EDITION,
4343
},
@@ -46,7 +46,16 @@ const getHostingProviderTests = [
4646
hello: [
4747
'server', 'redis',
4848
],
49-
info: '#Server\r\n'
49+
info: '# Server\r\n'
50+
+ 'executable:/data/redis-server',
51+
output: HostingProvider.REDIS_COMMUNITY_EDITION,
52+
},
53+
{
54+
input: 'localhost',
55+
hello: [
56+
'server', 'redis',
57+
],
58+
info: '# Server\r\n'
5059
+ 'executable:/opt/redis-stack/bin/redis-server',
5160
output: HostingProvider.REDIS_STACK,
5261
},
@@ -61,7 +70,7 @@ const getHostingProviderTests = [
6170
],
6271
],
6372
],
64-
info: '#Server\r\n'
73+
info: '# Server\r\n'
6574
+ 'redis_version: 7.2.0',
6675
output: HostingProvider.REDIS_ENTERPRISE,
6776
},
@@ -80,49 +89,49 @@ const getHostingProviderTests = [
8089
},
8190
{
8291
input: 'localhost',
83-
info: '#Server\r\n'
92+
info: '# Server\r\n'
8493
+ 'server_name:valkey',
8594
output: HostingProvider.VALKEY,
8695
},
8796
{
8897
input: 'localhost',
89-
info: '#Server\r\n'
98+
info: '# Server\r\n'
9099
+ 'dragonfly_version:df-7.0.0',
91100
output: HostingProvider.DRAGONFLY,
92101
},
93102
{
94103
input: 'localhost',
95-
info: '#Server\r\n'
104+
info: '# Server\r\n'
96105
+ 'garnet_version:gr-7.0.0',
97106
output: HostingProvider.GARNET,
98107
},
99108
{
100109
input: 'localhost',
101-
info: '#Server\r\n'
110+
info: '# Server\r\n'
102111
+ 'kvrocks_version:kv-7.0.0',
103112
output: HostingProvider.KVROCKS,
104113
},
105114
{
106115
input: 'localhost',
107-
info: '#Server\r\n'
116+
info: '# Server\r\n'
108117
+ 'redict_version:rd-7.0.0',
109118
output: HostingProvider.REDICT,
110119
},
111120
{
112121
input: 'localhost',
113-
info: '#Server\r\n'
122+
info: '# Server\r\n'
114123
+ 'upstash_version:up-7.0.0',
115124
output: HostingProvider.UPSTASH,
116125
},
117126
{
118127
input: 'localhost',
119-
info: '#Server\r\n'
128+
info: '# Server\r\n'
120129
+ 'ElastiCache:sometinhg',
121130
output: HostingProvider.AWS_ELASTICACHE,
122131
},
123132
{
124133
input: 'localhost',
125-
info: '#Server\r\n'
134+
info: '# Server\r\n'
126135
+ 'MemoryDB:sometinhg',
127136
output: HostingProvider.AWS_MEMORYDB,
128137
},

redisinsight/api/src/utils/hosting-provider-helper.ts

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { IP_ADDRESS_REGEX, PRIVATE_IP_ADDRESS_REGEX } from 'src/constants';
22
import { HostingProvider } from 'src/modules/database/entities/database.entity';
33
import { RedisClient } from 'src/modules/redis/client';
4+
import { convertRedisInfoReplyToObject } from 'src/utils/redis-reply-converter';
45

56
const PROVIDER_HOST_REGEX = {
67
RLCP: /\.rlrcp\.com$/,
@@ -97,12 +98,13 @@ export const getHostingProvider = async (client: RedisClient, databaseHost: stri
9798
return HostingProvider.UPSTASH;
9899
}
99100

100-
if (info.includes('executable:/opt/redis/bin/redis-server')) {
101-
return HostingProvider.REDIS_COMMUNITY_EDITION;
102-
}
101+
const infoObj = convertRedisInfoReplyToObject(info);
103102

104-
if (info.includes('executable:/opt/redis-stack/bin/redis-server')) {
105-
return HostingProvider.REDIS_STACK;
103+
if (infoObj.server.executable.includes('redis-server')) {
104+
if (infoObj.server.executable.includes('redis-stack')) {
105+
return HostingProvider.REDIS_STACK;
106+
}
107+
return HostingProvider.REDIS_COMMUNITY_EDITION;
106108
}
107109
} catch (e) {
108110
// ignore error

0 commit comments

Comments
 (0)