Fossil SCM

Add the "main-url" setting. Use it to send the "pragma from-url" on a sync. The server uses this to add new syncwith: entries for the client.

drh 2021-08-17 17:13 trunk
Commit 2ae7a5160ffde01945e5326c97a82a5c240986359ad103fab1e55c82cc6bf126
2 files changed +10 +38 -6
+10
--- src/setup.c
+++ src/setup.c
@@ -1053,10 +1053,20 @@
10531053
@ to download a ZIP archive or a tarball of the project. By default,
10541054
@ the latest trunk check-in is downloaded. Change this tag to something
10551055
@ else (ex: release) to alter the behavior of the /download page.
10561056
@ (Property: "download-tag")
10571057
@ </p>
1058
+ @ <hr />
1059
+ entry_attribute("Main URL", 60, "main-url", "exturl", "", 0);
1060
+ @ <p>Enter the canonical URL used to access this repository from the
1061
+ @ internet. If this repository is not set up as a server, leave this
1062
+ @ entry blank.
1063
+ @
1064
+ @ <p>This entry is not required. It is informational only. Inaccurate
1065
+ @ entries here will cause goofy URLs to appear under the /urllist page
1066
+ @ of sync partners, but are otherwise harmless.
1067
+ @ (Property: "main-url")
10581068
@ <hr />
10591069
entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0);
10601070
@ <p>Enter the pathname of the page to display when the "Home" menu
10611071
@ option is selected and when no pathname is
10621072
@ specified in the URL. For example, if you visit the url:</p>
10631073
--- src/setup.c
+++ src/setup.c
@@ -1053,10 +1053,20 @@
1053 @ to download a ZIP archive or a tarball of the project. By default,
1054 @ the latest trunk check-in is downloaded. Change this tag to something
1055 @ else (ex: release) to alter the behavior of the /download page.
1056 @ (Property: "download-tag")
1057 @ </p>
 
 
 
 
 
 
 
 
 
 
1058 @ <hr />
1059 entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0);
1060 @ <p>Enter the pathname of the page to display when the "Home" menu
1061 @ option is selected and when no pathname is
1062 @ specified in the URL. For example, if you visit the url:</p>
1063
--- src/setup.c
+++ src/setup.c
@@ -1053,10 +1053,20 @@
1053 @ to download a ZIP archive or a tarball of the project. By default,
1054 @ the latest trunk check-in is downloaded. Change this tag to something
1055 @ else (ex: release) to alter the behavior of the /download page.
1056 @ (Property: "download-tag")
1057 @ </p>
1058 @ <hr />
1059 entry_attribute("Main URL", 60, "main-url", "exturl", "", 0);
1060 @ <p>Enter the canonical URL used to access this repository from the
1061 @ internet. If this repository is not set up as a server, leave this
1062 @ entry blank.
1063 @
1064 @ <p>This entry is not required. It is informational only. Inaccurate
1065 @ entries here will cause goofy URLs to appear under the /urllist page
1066 @ of sync partners, but are otherwise harmless.
1067 @ (Property: "main-url")
1068 @ <hr />
1069 entry_attribute("Index Page", 60, "index-page", "idxpg", "/home", 0);
1070 @ <p>Enter the pathname of the page to display when the "Home" menu
1071 @ option is selected and when no pathname is
1072 @ specified in the URL. For example, if you visit the url:</p>
1073
+38 -6
--- src/xfer.c
+++ src/xfer.c
@@ -1577,21 +1577,21 @@
15771577
if( !g.perm.Private ){
15781578
server_private_xfer_not_authorized();
15791579
}else{
15801580
xfer.syncPrivate = 1;
15811581
}
1582
- }
1582
+ }else
15831583
15841584
/* pragma send-catalog
15851585
**
15861586
** The client wants to see igot cards for all known artifacts.
15871587
** This is used as part of "sync --verily" to help ensure that
15881588
** no artifacts have been missed on prior syncs.
15891589
*/
15901590
if( blob_eq(&xfer.aToken[1], "send-catalog") ){
15911591
xfer.resync = 0x7fffffff;
1592
- }
1592
+ }else
15931593
15941594
/* pragma client-version VERSION ?DATE? ?TIME?
15951595
**
15961596
** The client announces to the server what version of Fossil it
15971597
** is running. The DATE and TIME are a pure numeric ISO8601 time
@@ -1603,11 +1603,11 @@
16031603
xfer.remoteDate = atoi(blob_str(&xfer.aToken[3]));
16041604
xfer.remoteTime = atoi(blob_str(&xfer.aToken[4]));
16051605
@ pragma server-version %d(RELEASE_VERSION_NUMBER) \
16061606
@ %d(MANIFEST_NUMERIC_DATE) %d(MANIFEST_NUMERIC_TIME)
16071607
}
1608
- }
1608
+ }else
16091609
16101610
/* pragma uv-hash HASH
16111611
**
16121612
** The client wants to make sure that unversioned files are all synced.
16131613
** If the HASH does not match, send a complete catalog of
@@ -1626,11 +1626,11 @@
16261626
@ pragma uv-pull-only
16271627
}
16281628
send_unversioned_catalog(&xfer);
16291629
}
16301630
uvCatalogSent = 1;
1631
- }
1631
+ }else
16321632
16331633
/* pragma ci-lock CHECKIN-HASH CLIENT-ID
16341634
**
16351635
** The client wants to make non-branch commit against the check-in
16361636
** identified by CHECKIN-HASH. The server will remember this and
@@ -1686,11 +1686,11 @@
16861686
db_protect_pop();
16871687
}
16881688
if( db_get_boolean("forbid-delta-manifests",0) ){
16891689
@ pragma avoid-delta-manifests
16901690
}
1691
- }
1691
+ }else
16921692
16931693
/* pragma ci-unlock CLIENT-ID
16941694
**
16951695
** Remove any locks previously held by CLIENT-ID. Clients send this
16961696
** pragma with their own ID whenever they know that they no longer
@@ -1706,12 +1706,34 @@
17061706
" WHERE name GLOB 'ci-lock-*'"
17071707
" AND json_extract(value,'$.clientid')=%Q",
17081708
blob_str(&xfer.aToken[2])
17091709
);
17101710
db_protect_pop();
1711
- }
1711
+ }else
17121712
1713
+ /* pragma from-url URL
1714
+ **
1715
+ ** By this pragma, the client proclaims that it can be reached
1716
+ ** as a server located at URL.
1717
+ **
1718
+ ** If the user has write permission, then record the URL as a sync
1719
+ ** partner so that it shows up in /urllist pages.
1720
+ */
1721
+ if( blob_eq(&xfer.aToken[1], "from-url") ){
1722
+ if( xfer.nToken==3
1723
+ && blob_size(&xfer.aToken[2])>4
1724
+ && g.perm.Write
1725
+ ){
1726
+ db_unprotect(PROTECT_CONFIG);
1727
+ db_multi_exec(
1728
+ "REPLACE INTO config(name,value,mtime)"
1729
+ "VALUES('syncwith:%q',1,now())",
1730
+ blob_str(&xfer.aToken[2])
1731
+ );
1732
+ db_protect_pop();
1733
+ }
1734
+ }
17131735
}else
17141736
17151737
/* Unknown message
17161738
*/
17171739
{
@@ -2109,10 +2131,20 @@
21092131
blob_appendf(&send, "pragma ci-lock %s %s\n", zCkinLock, zClientId);
21102132
zCkinLock = 0;
21112133
}else if( zClientId ){
21122134
blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
21132135
}
2136
+
2137
+ /* If this repository has a main-url, let the other side know about
2138
+ ** it.
2139
+ */
2140
+ if( (syncFlags && SYNC_PUSH)!=0 && nCycle==0 ){
2141
+ const char *zSelfUrl = db_get("main-url",0);
2142
+ if( zSelfUrl && zSelfUrl[0]!=0 ){
2143
+ blob_appendf(&send, "pragma from-url %s\n", zSelfUrl);
2144
+ }
2145
+ }
21142146
21152147
/* Append randomness to the end of the uplink message. This makes all
21162148
** messages unique so that that the login-card nonce will always
21172149
** be unique.
21182150
*/
21192151
--- src/xfer.c
+++ src/xfer.c
@@ -1577,21 +1577,21 @@
1577 if( !g.perm.Private ){
1578 server_private_xfer_not_authorized();
1579 }else{
1580 xfer.syncPrivate = 1;
1581 }
1582 }
1583
1584 /* pragma send-catalog
1585 **
1586 ** The client wants to see igot cards for all known artifacts.
1587 ** This is used as part of "sync --verily" to help ensure that
1588 ** no artifacts have been missed on prior syncs.
1589 */
1590 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1591 xfer.resync = 0x7fffffff;
1592 }
1593
1594 /* pragma client-version VERSION ?DATE? ?TIME?
1595 **
1596 ** The client announces to the server what version of Fossil it
1597 ** is running. The DATE and TIME are a pure numeric ISO8601 time
@@ -1603,11 +1603,11 @@
1603 xfer.remoteDate = atoi(blob_str(&xfer.aToken[3]));
1604 xfer.remoteTime = atoi(blob_str(&xfer.aToken[4]));
1605 @ pragma server-version %d(RELEASE_VERSION_NUMBER) \
1606 @ %d(MANIFEST_NUMERIC_DATE) %d(MANIFEST_NUMERIC_TIME)
1607 }
1608 }
1609
1610 /* pragma uv-hash HASH
1611 **
1612 ** The client wants to make sure that unversioned files are all synced.
1613 ** If the HASH does not match, send a complete catalog of
@@ -1626,11 +1626,11 @@
1626 @ pragma uv-pull-only
1627 }
1628 send_unversioned_catalog(&xfer);
1629 }
1630 uvCatalogSent = 1;
1631 }
1632
1633 /* pragma ci-lock CHECKIN-HASH CLIENT-ID
1634 **
1635 ** The client wants to make non-branch commit against the check-in
1636 ** identified by CHECKIN-HASH. The server will remember this and
@@ -1686,11 +1686,11 @@
1686 db_protect_pop();
1687 }
1688 if( db_get_boolean("forbid-delta-manifests",0) ){
1689 @ pragma avoid-delta-manifests
1690 }
1691 }
1692
1693 /* pragma ci-unlock CLIENT-ID
1694 **
1695 ** Remove any locks previously held by CLIENT-ID. Clients send this
1696 ** pragma with their own ID whenever they know that they no longer
@@ -1706,12 +1706,34 @@
1706 " WHERE name GLOB 'ci-lock-*'"
1707 " AND json_extract(value,'$.clientid')=%Q",
1708 blob_str(&xfer.aToken[2])
1709 );
1710 db_protect_pop();
1711 }
1712
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1713 }else
1714
1715 /* Unknown message
1716 */
1717 {
@@ -2109,10 +2131,20 @@
2109 blob_appendf(&send, "pragma ci-lock %s %s\n", zCkinLock, zClientId);
2110 zCkinLock = 0;
2111 }else if( zClientId ){
2112 blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
2113 }
 
 
 
 
 
 
 
 
 
 
2114
2115 /* Append randomness to the end of the uplink message. This makes all
2116 ** messages unique so that that the login-card nonce will always
2117 ** be unique.
2118 */
2119
--- src/xfer.c
+++ src/xfer.c
@@ -1577,21 +1577,21 @@
1577 if( !g.perm.Private ){
1578 server_private_xfer_not_authorized();
1579 }else{
1580 xfer.syncPrivate = 1;
1581 }
1582 }else
1583
1584 /* pragma send-catalog
1585 **
1586 ** The client wants to see igot cards for all known artifacts.
1587 ** This is used as part of "sync --verily" to help ensure that
1588 ** no artifacts have been missed on prior syncs.
1589 */
1590 if( blob_eq(&xfer.aToken[1], "send-catalog") ){
1591 xfer.resync = 0x7fffffff;
1592 }else
1593
1594 /* pragma client-version VERSION ?DATE? ?TIME?
1595 **
1596 ** The client announces to the server what version of Fossil it
1597 ** is running. The DATE and TIME are a pure numeric ISO8601 time
@@ -1603,11 +1603,11 @@
1603 xfer.remoteDate = atoi(blob_str(&xfer.aToken[3]));
1604 xfer.remoteTime = atoi(blob_str(&xfer.aToken[4]));
1605 @ pragma server-version %d(RELEASE_VERSION_NUMBER) \
1606 @ %d(MANIFEST_NUMERIC_DATE) %d(MANIFEST_NUMERIC_TIME)
1607 }
1608 }else
1609
1610 /* pragma uv-hash HASH
1611 **
1612 ** The client wants to make sure that unversioned files are all synced.
1613 ** If the HASH does not match, send a complete catalog of
@@ -1626,11 +1626,11 @@
1626 @ pragma uv-pull-only
1627 }
1628 send_unversioned_catalog(&xfer);
1629 }
1630 uvCatalogSent = 1;
1631 }else
1632
1633 /* pragma ci-lock CHECKIN-HASH CLIENT-ID
1634 **
1635 ** The client wants to make non-branch commit against the check-in
1636 ** identified by CHECKIN-HASH. The server will remember this and
@@ -1686,11 +1686,11 @@
1686 db_protect_pop();
1687 }
1688 if( db_get_boolean("forbid-delta-manifests",0) ){
1689 @ pragma avoid-delta-manifests
1690 }
1691 }else
1692
1693 /* pragma ci-unlock CLIENT-ID
1694 **
1695 ** Remove any locks previously held by CLIENT-ID. Clients send this
1696 ** pragma with their own ID whenever they know that they no longer
@@ -1706,12 +1706,34 @@
1706 " WHERE name GLOB 'ci-lock-*'"
1707 " AND json_extract(value,'$.clientid')=%Q",
1708 blob_str(&xfer.aToken[2])
1709 );
1710 db_protect_pop();
1711 }else
1712
1713 /* pragma from-url URL
1714 **
1715 ** By this pragma, the client proclaims that it can be reached
1716 ** as a server located at URL.
1717 **
1718 ** If the user has write permission, then record the URL as a sync
1719 ** partner so that it shows up in /urllist pages.
1720 */
1721 if( blob_eq(&xfer.aToken[1], "from-url") ){
1722 if( xfer.nToken==3
1723 && blob_size(&xfer.aToken[2])>4
1724 && g.perm.Write
1725 ){
1726 db_unprotect(PROTECT_CONFIG);
1727 db_multi_exec(
1728 "REPLACE INTO config(name,value,mtime)"
1729 "VALUES('syncwith:%q',1,now())",
1730 blob_str(&xfer.aToken[2])
1731 );
1732 db_protect_pop();
1733 }
1734 }
1735 }else
1736
1737 /* Unknown message
1738 */
1739 {
@@ -2109,10 +2131,20 @@
2131 blob_appendf(&send, "pragma ci-lock %s %s\n", zCkinLock, zClientId);
2132 zCkinLock = 0;
2133 }else if( zClientId ){
2134 blob_appendf(&send, "pragma ci-unlock %s\n", zClientId);
2135 }
2136
2137 /* If this repository has a main-url, let the other side know about
2138 ** it.
2139 */
2140 if( (syncFlags && SYNC_PUSH)!=0 && nCycle==0 ){
2141 const char *zSelfUrl = db_get("main-url",0);
2142 if( zSelfUrl && zSelfUrl[0]!=0 ){
2143 blob_appendf(&send, "pragma from-url %s\n", zSelfUrl);
2144 }
2145 }
2146
2147 /* Append randomness to the end of the uplink message. This makes all
2148 ** messages unique so that that the login-card nonce will always
2149 ** be unique.
2150 */
2151

Keyboard Shortcuts

Open search /
Next entry (timeline) j
Previous entry (timeline) k
Open focused entry Enter
Show this help ?
Toggle theme Top nav button