Skip to content

Commit 06e6e57

Browse files
authored
Merge pull request #5 from CoNET-project/test
test
2 parents 3c05bf0 + bf95414 commit 06e6e57

File tree

13 files changed

+244
-74
lines changed

13 files changed

+244
-74
lines changed

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
work correctly both with client-side routing and a non-root public URL.
2323
Learn how to configure a non-root public URL by running `npm run build`.
2424
-->
25-
<title>Silent Pass VPN</title>
25+
<title>Silent Pass</title>
2626
</head>
2727

2828
<body>

src/App.tsx

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,12 @@ import Support from './pages/Support';
1717
import FAQ from './pages/FAQ';
1818
import ConfigDevice from './pages/ConfigDevice';
1919
import Passcode from './pages/Passcode';
20+
import { getServerIpAddress } from "./api";
2021

2122
global.Buffer = require('buffer').Buffer;
2223

2324
function App() {
24-
const { setProfile, setMiningData, allRegions, setClosestRegion, setaAllNodes } = useDaemonContext();
25+
const { setProfile, setMiningData, allRegions, setClosestRegion, setaAllNodes, setServerIpAddress, setServerPort, _vpnTimeUsedInMin } = useDaemonContext();
2526

2627
useEffect(() => {
2728
const handlePassport = async () => {
@@ -50,10 +51,29 @@ function App() {
5051
setProfile(CoNET_Data.profiles[0]);
5152
}
5253

54+
const _getServerIpAddress = async () => {
55+
try {
56+
const response = await getServerIpAddress();
57+
const tmpIpAddress = response.data;
58+
59+
setServerIpAddress(tmpIpAddress?.ip || "");
60+
setServerPort('3002');
61+
} catch (ex) {
62+
console.log(ex)
63+
}
64+
};
65+
5366
const init = async () => {
67+
const vpnTimeUsedInMin = parseInt(localStorage.getItem("vpnTimeUsedInMin") || "0");
68+
_vpnTimeUsedInMin.current = vpnTimeUsedInMin;
69+
5470
await createOrGetWallet();
5571
listenProfileVer(setProfile);
5672

73+
if (!window?.webkit) {
74+
_getServerIpAddress();
75+
}
76+
5777
await getAllNodes(allRegions, setClosestRegion, (allNodes: nodes_info[]) => {
5878
setaAllNodes(allNodes)
5979

src/api/index.ts

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,23 @@ export const startSilentPass = async (
2323
throw error;
2424
}
2525
};
26+
27+
export const stopSilentPass = async (): Promise<AxiosResponse<any>> => {
28+
try {
29+
const response = await api.get("/stopSilentPass");
30+
return response;
31+
} catch (error) {
32+
console.error("Error starting silent pass:", error);
33+
throw error;
34+
}
35+
};
36+
37+
export const getServerIpAddress = async (): Promise<AxiosResponse<any>> => {
38+
try {
39+
const response = await api.get("/ipaddress");
40+
return response;
41+
} catch (error) {
42+
console.error("Error fetching regions:", error);
43+
throw error;
44+
}
45+
};

src/components/CopyProxyInfo/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { useState } from 'react';
22
import Skeleton from '../Skeleton';
33

44
import { ReactComponent as ChevronArrow } from "./assets/right-chevron.svg";
5-
import { PROXY_PAC, PROXY_PORT, PROXY_SERVER } from '../../utils/constants';
5+
import { useDaemonContext } from '../../providers/DaemonProvider';
66

77
type CopyProxyInfoProps = {
88

@@ -14,6 +14,8 @@ export default function CopyProxyInfo({ }: CopyProxyInfoProps) {
1414
const [isProxyPortCopied, setIsProxyPortCopied] = useState<boolean>(false);
1515
const [isPACCopied, setIsPACCopied] = useState<boolean>(false);
1616

17+
const { serverIpAddress, serverPort, serverPac } = useDaemonContext();
18+
1719
const handleCopy = (text: string, setMethod: (val: boolean) => any) => {
1820
navigator.clipboard.writeText(text);
1921

@@ -35,8 +37,8 @@ export default function CopyProxyInfo({ }: CopyProxyInfoProps) {
3537
<p>Proxy server:</p>
3638
{
3739
true ? (
38-
<button onClick={() => handleCopy(PROXY_SERVER, setIsProxyServerCopied)}>
39-
<p>{PROXY_SERVER}</p>
40+
<button onClick={() => handleCopy(serverIpAddress, setIsProxyServerCopied)}>
41+
<p>{serverIpAddress}</p>
4042
{
4143
isProxyServerCopied ? (
4244
<img src="/assets/check.svg" alt="Copy icon" />
@@ -55,8 +57,8 @@ export default function CopyProxyInfo({ }: CopyProxyInfoProps) {
5557
<p>Proxy port:</p>
5658
{
5759
true ? (
58-
<button onClick={() => handleCopy(PROXY_PORT, setIsProxyPortCopied)}>
59-
<p>{PROXY_PORT}</p>
60+
<button onClick={() => handleCopy(serverPort, setIsProxyPortCopied)}>
61+
<p>{serverPort}</p>
6062
{
6163
isProxyPortCopied ? (
6264
<img src="/assets/check.svg" alt="Copy icon" />
@@ -75,8 +77,8 @@ export default function CopyProxyInfo({ }: CopyProxyInfoProps) {
7577
<p>PAC:</p>
7678
{
7779
true ? (
78-
<button onClick={() => handleCopy(PROXY_PAC, setIsPACCopied)}>
79-
<p>{PROXY_PAC}</p>
80+
<button onClick={() => handleCopy(serverPac, setIsPACCopied)}>
81+
<p>{serverPac}</p>
8082
{
8183
isPACCopied ? (
8284
<img src="/assets/check.svg" alt="Copy icon" />
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
.main-card {
2+
display: flex;
3+
justify-content: space-between;
4+
align-items: center;
5+
6+
background: #191919;
7+
padding: 16px;
8+
border-radius: 16px;
9+
}
10+
11+
.main-card span {
12+
font-size: 14px;
13+
color: #989899;
14+
}
15+
16+
.main-card p {
17+
font-size: 24px;
18+
}
19+
20+
.main-card div:last-child {
21+
text-align: right;
22+
}
23+
24+
.buttons {
25+
display: flex;
26+
gap: 8px;
27+
}
28+
29+
.buttons button {
30+
flex: 1;
31+
display: flex;
32+
justify-content: center;
33+
align-items: center;
34+
35+
padding: 16px 8px;
36+
border: 0;
37+
border-radius: 16px;
38+
font-weight: 700;
39+
40+
cursor: pointer;
41+
}
42+
43+
.buttons button:first-child {
44+
background-color: #282930;
45+
color: #ffffff;
46+
}
47+
48+
.buttons button:last-child {
49+
background-color: #9fbfe533;
50+
color: #9fbfe5fe;
51+
52+
display: flex;
53+
align-items: center;
54+
justify-content: center;
55+
gap: 8px;
56+
}
57+
58+
.disabled {
59+
background: #191919 !important;
60+
color: #5a5a5afe !important;
61+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import { useNavigate } from "react-router-dom";
2+
import { useDaemonContext } from "../../providers/DaemonProvider";
3+
import { getRemainingTime } from "../../utils/utils";
4+
import Skeleton from "../Skeleton";
5+
6+
const PassportInfo = () => {
7+
const navigate = useNavigate();
8+
const { profile } = useDaemonContext();
9+
10+
return (
11+
<div className="main-card">
12+
<div style={{ textAlign: 'start' }}>
13+
<span>Silent Pass Passport</span>
14+
<p>Freemium</p>
15+
</div>
16+
<div style={{ display: 'flex', flexDirection: 'column', alignItems: 'end' }}>
17+
<span>Expiration date</span>
18+
{
19+
profile?.activeFreePassport?.expires ?
20+
<p>{getRemainingTime(profile?.activeFreePassport?.expires)}</p>
21+
: <Skeleton width='50px' height='20px' />
22+
}
23+
</div>
24+
</div>
25+
);
26+
};
27+
28+
export default PassportInfo;

src/components/ProxyInfo/index.tsx

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,16 @@ import Separator from '../Separator';
66
import Skeleton from '../Skeleton';
77

88
import './index.css';
9-
import { PROXY_PAC, PROXY_PORT, PROXY_SERVER } from '../../utils/constants';
9+
import { useDaemonContext } from '../../providers/DaemonProvider';
1010

1111
export default function ProxyInfo() {
1212
const [isDropdownOpen, setIsDropdownOpen] = useState<boolean>(false);
1313
const [isProxyServerCopied, setIsProxyServerCopied] = useState<boolean>(false);
1414
const [isProxyPortCopied, setIsProxyPortCopied] = useState<boolean>(false);
1515
const [isPACCopied, setIsPACCopied] = useState<boolean>(false);
1616

17+
const { serverIpAddress, serverPort, serverPac } = useDaemonContext();
18+
1719
const handleCopy = (text: string, setMethod: (val: boolean) => any) => {
1820
navigator.clipboard.writeText(text);
1921

@@ -33,8 +35,8 @@ export default function ProxyInfo() {
3335
<ClickableItem title="Proxy server:" chevron={false}>
3436
{
3537
true ? (
36-
<button onClick={() => handleCopy(PROXY_SERVER, setIsProxyServerCopied)}>
37-
<p>{PROXY_SERVER}</p>
38+
<button onClick={() => handleCopy(serverIpAddress, setIsProxyServerCopied)}>
39+
<p>{serverIpAddress}</p>
3840
{
3941
isProxyServerCopied ? (
4042
<img src="/assets/check.svg" alt="Copy icon" />
@@ -52,8 +54,8 @@ export default function ProxyInfo() {
5254
<ClickableItem title="Proxy Port:" chevron={false}>
5355
{
5456
true ? (
55-
<button onClick={() => handleCopy(PROXY_PORT, setIsProxyPortCopied)}>
56-
<p>{PROXY_PORT}</p>
57+
<button onClick={() => handleCopy(serverPort, setIsProxyPortCopied)}>
58+
<p>{serverPort}</p>
5759
{
5860
isProxyPortCopied ? (
5961
<img src="/assets/check.svg" alt="Copy icon" />
@@ -71,8 +73,8 @@ export default function ProxyInfo() {
7173
<ClickableItem title="PAC:" chevron={false}>
7274
{
7375
true ? (
74-
<button onClick={() => handleCopy(PROXY_PAC, setIsPACCopied)}>
75-
<p>{PROXY_PAC}</p>
76+
<button onClick={() => handleCopy(serverPac, setIsPACCopied)}>
77+
<p>{serverPac}</p>
7678
{
7779
isPACCopied ? (
7880
<img src="/assets/check.svg" alt="Copy icon" />

src/pages/FAQ/index.tsx

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import SilentPassServiceTable from "./assets/silent-pass-service-table.svg";
44
import SilentPassBenefitsTable from "./assets/silent-pass-benefits-table.svg";
55

66
import "./index.css";
7-
import { PROXY_PAC, PROXY_PORT, PROXY_SERVER } from '../../utils/constants';
87

98
const FAQ = () => {
109
return (
@@ -76,16 +75,6 @@ const FAQ = () => {
7675
</li>
7776
</ol>
7877
</div>
79-
<div>
80-
<h3>Silent Pass Proxy Server Setting Parameters</h3>
81-
<p>
82-
Support Windows 10~, Linux & MacOS <br />
83-
Local Proxy Auto-Config (PAC) Url: <br />
84-
{PROXY_PAC} <br />
85-
Proxy server: {PROXY_SERVER} <br />
86-
Port number: {PROXY_PORT} <br />
87-
</p>
88-
</div>
8978
</div>
9079
);
9180
};

src/pages/Home/index.css

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ a {
99
align-items: center;
1010
position: absolute;
1111
top: 0;
12+
padding-top: 1rem;
1213
}
1314

1415
.header-content {
@@ -27,6 +28,7 @@ a {
2728
flex-direction: column;
2829
justify-content: space-evenly;
2930
align-items: center;
31+
overflow-y: auto;
3032
height: 100%;
3133
width: 90%;
3234
padding: 45px 0;
@@ -197,7 +199,7 @@ h1 span {
197199

198200
height: 31px;
199201

200-
transition: height .20s ease;
202+
transition: height 0.2s ease;
201203

202204
overflow: hidden;
203205
}
@@ -229,7 +231,7 @@ h1 span {
229231
}
230232

231233
.wallet-info-container hr {
232-
border-color: #3F3F40;
234+
border-color: #3f3f40;
233235
}
234236

235237
.wallet-info {
@@ -274,6 +276,7 @@ h1 span {
274276
flex-direction: column;
275277
align-items: center;
276278
line-height: 22px;
279+
padding-top: 3rem;
277280
}
278281

279282
.current-mined p,
@@ -344,5 +347,5 @@ h1 span {
344347
.button-wrapper {
345348
display: flex;
346349
flex-direction: column;
347-
gap: 2rem;
350+
gap: 2px;
348351
}

0 commit comments

Comments
 (0)