Skip to content

Commit 56d9170

Browse files
committed
Merge branch 'master' into ep/smp-rcv-service
2 parents 7e745c5 + 2cedb66 commit 56d9170

File tree

7 files changed

+15
-17
lines changed

7 files changed

+15
-17
lines changed

apps/smp-server/static/link.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -512,6 +512,8 @@ <h2 class="text-xl font-bold">If you already installed SimpleX Chat for the term
512512
element.innerHTML = 'This is a one-time link of the SimpleX&nbsp;network user'
513513
} else if (url.includes('/c')) {
514514
element.innerHTML = 'This is a public channel address on SimpleX&nbsp;network'
515+
} else if (url.includes('/r')) {
516+
element.innerHTML = 'This is a chat relay address on SimpleX&nbsp;network'
515517
}
516518
}
517519
</script>

apps/smp-server/web/Static.hs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,7 @@ generateSite si onionHost sitePath = do
103103
createLinkPage "a"
104104
createLinkPage "c"
105105
createLinkPage "g"
106+
createLinkPage "r"
106107
createLinkPage "i"
107108
logInfo $ "Generated static site contents at " <> tshow sitePath
108109
where

src/Simplex/Messaging/Agent/Protocol.hs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1129,7 +1129,7 @@ instance StrEncoding AConnectionRequestUri where
11291129

11301130
connReqUriP :: Maybe ServiceScheme -> Parser AConnectionRequestUri
11311131
connReqUriP overrideScheme = do
1132-
crScheme <- (`fromMaybe` overrideScheme) <$> strP
1132+
crScheme <- (`fromMaybe` overrideScheme) <$> strP -- always parse, but use the passed one if any
11331133
crMode <- A.char '/' *> crModeP <* optional (A.char '/') <* "#/?"
11341134
query <- strP
11351135
aVRange <- queryParam "v" query
@@ -1445,7 +1445,7 @@ instance ConnectionModeI c => ToField (ConnShortLink c) where toField = toField
14451445

14461446
instance (Typeable c, ConnectionModeI c) => FromField (ConnShortLink c) where fromField = blobFieldDecoder strDecode
14471447

1448-
data ContactConnType = CCTContact | CCTChannel | CCTGroup deriving (Eq, Show)
1448+
data ContactConnType = CCTContact | CCTChannel | CCTGroup | CCTRelay deriving (Eq, Show)
14491449

14501450
data AConnShortLink = forall m. ConnectionModeI m => ACSL (SConnectionMode m) (ConnShortLink m)
14511451

@@ -1593,6 +1593,7 @@ ctTypeP = \case
15931593
'A' -> pure CCTContact
15941594
'C' -> pure CCTChannel
15951595
'G' -> pure CCTGroup
1596+
'R' -> pure CCTRelay
15961597
_ -> fail "unknown contact address type"
15971598
{-# INLINE ctTypeP #-}
15981599

@@ -1601,6 +1602,7 @@ ctTypeChar = \case
16011602
CCTContact -> 'A'
16021603
CCTChannel -> 'C'
16031604
CCTGroup -> 'G'
1605+
CCTRelay -> 'R'
16041606
{-# INLINE ctTypeChar #-}
16051607

16061608
-- the servers passed to this function should be all preset servers, not servers configured by the user.

src/Simplex/Messaging/Server/Information.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import qualified Data.Attoparsec.ByteString.Char8 as A
1414
import Data.Int (Int64)
1515
import Data.Maybe (isJust)
1616
import Data.Text (Text)
17-
import Simplex.Messaging.Agent.Protocol (ConnectionMode (..), ConnectionRequestUri)
17+
import Simplex.Messaging.Agent.Protocol (ConnectionLink, ConnectionMode (..), ConnectionRequestUri)
1818
import Simplex.Messaging.Encoding.String
1919
import Simplex.Messaging.Parsers (defaultJSON, dropPrefix, enumJSON)
2020

@@ -100,7 +100,7 @@ data Entity = Entity {name :: Text, country :: Maybe Text}
100100
deriving (Show)
101101

102102
data ServerContactAddress = ServerContactAddress
103-
{ simplex :: Maybe (ConnectionRequestUri 'CMContact),
103+
{ simplex :: Maybe (ConnectionLink 'CMContact),
104104
email :: Maybe Text, -- it is recommended that it matches DNS email address, if either is present
105105
pgp :: Maybe PGPKey
106106
}

src/Simplex/Messaging/Server/Main.hs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ import qualified Data.Text as T
3737
import Data.Text.Encoding (decodeLatin1, encodeUtf8)
3838
import qualified Data.Text.IO as T
3939
import Options.Applicative
40-
import Simplex.Messaging.Agent.Protocol (connReqUriP')
40+
import Simplex.Messaging.Agent.Protocol (ConnectionLink (..), connReqUriP')
4141
import Simplex.Messaging.Agent.Store.Postgres.Options (DBOpts (..))
4242
import Simplex.Messaging.Agent.Store.Shared (MigrationConfirmation (..))
4343
import Simplex.Messaging.Client (HostMode (..), NetworkConfig (..), ProtocolClientConfig (..), SMPWebPortServers (..), SocksMode (..), defaultNetworkConfig, textToHostMode)
@@ -638,7 +638,8 @@ serverPublicInfo ini = serverInfo <$!> infoValue "source_code"
638638
<$!> infoValue nameField
639639
countryValue field = (either error id . validCountryValue (T.unpack field) . T.unpack) <$!> infoValue field
640640
iniContacts simplexField emailField pgpKeyUriField pgpKeyFingerprintField =
641-
let simplex = either error id . parseAll (connReqUriP' Nothing) . encodeUtf8 <$!> eitherToMaybe (lookupValue "INFORMATION" simplexField ini)
641+
let simplex = either error id . parseAll linkP . encodeUtf8 <$!> eitherToMaybe (lookupValue "INFORMATION" simplexField ini)
642+
linkP = CLFull <$> connReqUriP' Nothing <|> CLShort <$> strP
642643
email = infoValue emailField
643644
pkURI_ = infoValue pgpKeyUriField
644645
pkFingerprint_ = infoValue pgpKeyFingerprintField

src/Simplex/Messaging/Transport/Credentials.hs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,14 +25,6 @@ import qualified Simplex.Messaging.Crypto as C
2525
import qualified Time.System as Hourglass
2626
import qualified Time.Types as HT
2727

28-
-- | Generate a certificate chain to be used with TLS fingerprint-pinning
29-
--
30-
-- @
31-
-- genTlsCredentials = do
32-
-- ca <- genCredentials Nothing (-25, 365 * 24) "Root" -- long-lived root cert
33-
-- leaf <- genCredentials (Just ca) (0, 1) "Entity" -- session-signing cert
34-
-- pure $ tlsCredentials (leaf :| [ca])
35-
-- @
3628
tlsCredentials :: NonEmpty Credentials -> (C.KeyHash, TLS.Credential)
3729
tlsCredentials credentials = (C.KeyHash rootFP, (X509.CertificateChain certs, privateToTls $ snd leafKey))
3830
where

src/Simplex/RemoteControl/Client.hs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ encInvitationSize = 900
8585

8686
newRCHostPairing :: TVar ChaChaDRG -> IO RCHostPairing
8787
newRCHostPairing drg = do
88-
((_, caKey), caCert) <- genCredentials drg Nothing (-25, 24 * 999999) "ca"
88+
((_, caKey), caCert) <- genCredentials drg Nothing (25, 24 * 999999) "ca"
8989
(_, idPrivKey) <- atomically $ C.generateKeyPair drg
9090
pure RCHostPairing {caKey, caCert, idPrivKey, knownHost = Nothing}
9191

@@ -193,7 +193,7 @@ connectRCHost drg pairing@RCHostPairing {caKey, caCert, idPrivKey, knownHost} ct
193193
genTLSCredentials :: TVar ChaChaDRG -> C.APrivateSignKey -> X.SignedCertificate -> IO TLS.Credential
194194
genTLSCredentials drg caKey caCert = do
195195
let caCreds = (C.signatureKeyPair caKey, caCert)
196-
leaf <- genCredentials drg (Just caCreds) (0, 24 * 999999) "localhost" -- session-signing cert
196+
leaf <- genCredentials drg (Just caCreds) (1, 24 * 999999) "localhost" -- session-signing cert
197197
pure . snd $ tlsCredentials (leaf :| [caCreds])
198198

199199
certFingerprint :: X.SignedCertificate -> C.KeyHash
@@ -259,7 +259,7 @@ connectRCCtrl drg (RCVerifiedInvitation inv@RCInvitation {ca, idkey}) pairing_ h
259259
where
260260
newCtrlPairing :: IO RCCtrlPairing
261261
newCtrlPairing = do
262-
((_, caKey), caCert) <- genCredentials drg Nothing (0, 24 * 999999) "ca"
262+
((_, caKey), caCert) <- genCredentials drg Nothing (1, 24 * 999999) "ca"
263263
(_, dhPrivKey) <- atomically $ C.generateKeyPair drg
264264
pure RCCtrlPairing {caKey, caCert, ctrlFingerprint = ca, idPubKey = idkey, dhPrivKey, prevDhPrivKey = Nothing}
265265
updateCtrlPairing :: RCCtrlPairing -> ExceptT RCErrorType IO RCCtrlPairing

0 commit comments

Comments
 (0)