<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: mstmdev</title>
    <description>The latest articles on DEV Community by mstmdev (@mstmdev).</description>
    <link>https://dev.to/mstmdev</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F878763%2F173a4608-bc76-42d1-8ba6-cb023f1d8fe7.jpeg</url>
      <title>DEV Community: mstmdev</title>
      <link>https://dev.to/mstmdev</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/mstmdev"/>
    <language>en</language>
    <item>
      <title>gofs-A cross-platform file synchronization tool out of the box based on golang</title>
      <dc:creator>mstmdev</dc:creator>
      <pubDate>Fri, 17 Jun 2022 17:08:38 +0000</pubDate>
      <link>https://dev.to/mstmdev/gofs-a-cross-platform-file-synchronization-tool-out-of-the-box-based-on-golang-4kec</link>
      <guid>https://dev.to/mstmdev/gofs-a-cross-platform-file-synchronization-tool-out-of-the-box-based-on-golang-4kec</guid>
      <description>&lt;h2&gt;
  
  
  Github Repo
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://github.com/no-src/gofs"&gt;https://github.com/no-src/gofs&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Installation
&lt;/h2&gt;

&lt;p&gt;The first need &lt;a href="https://go.dev/doc/install"&gt;Go&lt;/a&gt; installed (&lt;strong&gt;version 1.18+ is required&lt;/strong&gt;), then you can use the below command to install &lt;code&gt;gofs&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install &lt;/span&gt;github.com/no-src/gofs/...@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Run In Docker
&lt;/h3&gt;

&lt;p&gt;If you want to run in a docker, you should install or build with the &lt;code&gt;-tags netgo&lt;/code&gt; flag or set the&lt;br&gt;
environment &lt;code&gt;CGO_ENABLED=0&lt;/code&gt;, otherwise you may get an error that the &lt;code&gt;gofs&lt;/code&gt; not found, when the docker container is&lt;br&gt;
running.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;go &lt;span class="nb"&gt;install&lt;/span&gt; &lt;span class="nt"&gt;-tags&lt;/span&gt; netgo github.com/no-src/gofs/...@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can use the &lt;a href="https://github.com/no-src/gofs/blob/main/scripts/build-docker.sh"&gt;build-docker.sh&lt;/a&gt; script to build the docker image and you should clone this&lt;br&gt;
repository and &lt;code&gt;cd&lt;/code&gt; to the root path of the repository first.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;./scripts/build-docker.sh
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or pull the docker image directly from &lt;a href="https://hub.docker.com/r/nosrc/gofs"&gt;DockerHub&lt;/a&gt; with the command below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;docker pull nosrc/gofs
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;For more scripts about release and docker, see the &lt;a href="https://github.com/no-src/gofs/blob/main/scripts"&gt;scripts&lt;/a&gt; directory.&lt;/p&gt;

&lt;h3&gt;
  
  
  Run In the Background
&lt;/h3&gt;

&lt;p&gt;You can install a program run in the background using the following command on Windows.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight batchfile"&gt;&lt;code&gt;&lt;span class="kd"&gt;go&lt;/span&gt; &lt;span class="kd"&gt;install&lt;/span&gt; &lt;span class="na"&gt;-ldflags&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"-H windowsgui"&lt;/span&gt; &lt;span class="kd"&gt;github&lt;/span&gt;.com/no&lt;span class="na"&gt;-src/gofs&lt;/span&gt;/...@latest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Quick Start
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Prerequisites
&lt;/h3&gt;

&lt;p&gt;Please ensure the source directory and dest directory exists first, replace the following path with your real path.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;mkdir source &lt;/span&gt;dest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Generate the TLS cert file and key file for testing purposes.&lt;/p&gt;

&lt;p&gt;The TLS cert and key files are just used by &lt;a href="https://github.com/no-src/gofs#file-server"&gt;File Server&lt;/a&gt; and &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;go run &lt;span class="nv"&gt;$GOROOT&lt;/span&gt;/src/crypto/tls/generate_cert.go &lt;span class="nt"&gt;--host&lt;/span&gt; 127.0.0.1
2021/12/30 17:21:54 wrote cert.pem
2021/12/30 17:21:54 wrote key.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Look up our workspace.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;&lt;span class="nb"&gt;ls
&lt;/span&gt;cert.pem  key.pem  &lt;span class="nb"&gt;source  &lt;/span&gt;dest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Local Disk
&lt;/h3&gt;

&lt;p&gt;Monitor source directory and sync change files to dest directory.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;logically_delete&lt;/code&gt; flag to enable the logically delete and avoid deleting files by mistake.&lt;/p&gt;

&lt;p&gt;Set the &lt;code&gt;checkpoint_count&lt;/code&gt; flag to use the checkpoint in the file to reduce transfer unmodified file chunks, by&lt;br&gt;
default &lt;code&gt;checkpoint_count=10&lt;/code&gt;, which means it has &lt;code&gt;10+2&lt;/code&gt; checkpoints at most. There are two additional checkpoints at&lt;br&gt;
the head and tail. The first checkpoint is equal to the &lt;code&gt;chunk_size&lt;/code&gt;, it is optional. The last checkpoint is equal to&lt;br&gt;
the file size, it is required. The checkpoint offset set by the &lt;code&gt;checkpoint_count&lt;/code&gt; is always more than &lt;code&gt;chunk_size&lt;/code&gt;,&lt;br&gt;
unless the file size is less than or equal to &lt;code&gt;chunk_size&lt;/code&gt;, then the &lt;code&gt;checkpoint_count&lt;/code&gt; will be zero, so it is optional.&lt;/p&gt;

&lt;p&gt;By default, if the file size and file modification time of the source file is equal to the destination file, then ignore&lt;br&gt;
the current file transfer. You can use the &lt;code&gt;force_checksum&lt;/code&gt; flag to force enable the checksum to compare whether the&lt;br&gt;
file is equal or not.&lt;/p&gt;

&lt;p&gt;The default checksum hash algorithm is &lt;code&gt;md5&lt;/code&gt;, you can use the &lt;code&gt;checksum_algorithm&lt;/code&gt; flag to change the default hash&lt;br&gt;
algorithm, current supported algorithms: &lt;code&gt;md5&lt;/code&gt;, &lt;code&gt;sha1&lt;/code&gt;, &lt;code&gt;sha256&lt;/code&gt;, &lt;code&gt;sha512&lt;/code&gt;, &lt;code&gt;crc32&lt;/code&gt;, &lt;code&gt;crc64&lt;/code&gt;, &lt;code&gt;adler32&lt;/code&gt;, &lt;code&gt;fnv-1-32&lt;/code&gt;&lt;br&gt;
, &lt;code&gt;fnv-1a-32&lt;/code&gt;, &lt;code&gt;fnv-1-64&lt;/code&gt;, &lt;code&gt;fnv-1a-64&lt;/code&gt;, &lt;code&gt;fnv-1-128&lt;/code&gt;, &lt;code&gt;fnv-1a-128&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you want to reduce the frequency of synchronization, you can use the &lt;code&gt;sync_delay&lt;/code&gt; flag to enable sync delay, start&lt;br&gt;
sync when the event count is equal or greater than &lt;code&gt;sync_delay_events&lt;/code&gt;, or wait for &lt;code&gt;sync_delay_time&lt;/code&gt; interval time&lt;br&gt;
since the last sync.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sync Once
&lt;/h3&gt;

&lt;p&gt;Sync the whole path immediately from source directory to dest directory.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-sync_once&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Sync Cron
&lt;/h3&gt;

&lt;p&gt;Sync the whole path from source directory to dest directory with cron.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Per 30 seconds sync the whole path from source directory to dest directory&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-sync_cron&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"*/30 * * * * *"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Daemon Mode
&lt;/h3&gt;

&lt;p&gt;Start a daemon to create subprocess to work, and record pid info to pid file.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-daemon&lt;/span&gt; &lt;span class="nt"&gt;-daemon_pid&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  File Server
&lt;/h3&gt;

&lt;p&gt;Start a file server for source directory and dest directory.&lt;/p&gt;

&lt;p&gt;The file server is use HTTPS default, set the &lt;code&gt;tls_cert_file&lt;/code&gt; and &lt;code&gt;tls_key_file&lt;/code&gt; flags to customize the cert file and&lt;br&gt;
key file.&lt;/p&gt;

&lt;p&gt;You can disable the HTTPS by set the &lt;code&gt;tls&lt;/code&gt; flag to &lt;code&gt;false&lt;/code&gt; if you don't need it.&lt;/p&gt;

&lt;p&gt;If you set the &lt;code&gt;tls&lt;/code&gt; to &lt;code&gt;true&lt;/code&gt;, the file server default port is &lt;code&gt;443&lt;/code&gt;, otherwise it is &lt;code&gt;80&lt;/code&gt;, and you can customize the&lt;br&gt;
default port with the &lt;code&gt;server_addr&lt;/code&gt; flag, like &lt;code&gt;-server_addr=":443"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;If you enable the &lt;code&gt;tls&lt;/code&gt; flag on the server side, you can control whether a client skip verifies the server's certificate&lt;br&gt;
chain and host name by the &lt;code&gt;tls_insecure_skip_verify&lt;/code&gt; flag, default is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You should set the &lt;code&gt;rand_user_count&lt;/code&gt; flag to auto generate some random users or set the &lt;code&gt;users&lt;/code&gt; flag to customize server&lt;br&gt;
users for security reasons.&lt;/p&gt;

&lt;p&gt;The server users will output to log if you set the &lt;code&gt;rand_user_count&lt;/code&gt; flag greater than zero.&lt;/p&gt;

&lt;p&gt;If you need to compress the files, add the &lt;code&gt;server_compress&lt;/code&gt; flag to enable gzip compression for response, but it is not&lt;br&gt;
fast now, and may reduce transmission efficiency in the LAN.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a file server and create three random users&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `tls_cert_file` and `tls_key_file` flags with your real cert files in the production environment&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-server&lt;/span&gt; &lt;span class="nt"&gt;-tls_cert_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cert.pem &lt;span class="nt"&gt;-tls_key_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;key.pem &lt;span class="nt"&gt;-rand_user_count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remote Disk Server
&lt;/h3&gt;

&lt;p&gt;Start a remote disk server as a remote file source.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;source&lt;/code&gt; flag detail see &lt;a href="https://github.com/no-src/gofs#remote-server-source-protocol"&gt;Remote Server Source Protocol&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Pay attention to that remote disk server users must have read permission at least, for&lt;br&gt;
example, &lt;code&gt;-users="gofs|password|r"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;checkpoint_count&lt;/code&gt; and &lt;code&gt;sync_delay&lt;/code&gt; flags like the &lt;a href="https://github.com/no-src/gofs#local-disk"&gt;Local Disk&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a remote disk server&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `tls_cert_file` and `tls_key_file` flags with your real cert files in the production environment&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `users` flag with complex username and password for security&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rs://127.0.0.1:8105?mode=server&amp;amp;local_sync_disabled=true&amp;amp;path=./source&amp;amp;fs_server=https://127.0.0.1"&lt;/span&gt; &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-users&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gofs|password|r"&lt;/span&gt; &lt;span class="nt"&gt;-tls_cert_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cert.pem &lt;span class="nt"&gt;-tls_key_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;key.pem
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remote Disk Client
&lt;/h3&gt;

&lt;p&gt;Start a remote disk client to sync change files from remote disk server.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;source&lt;/code&gt; flag detail see &lt;a href="https://github.com/no-src/gofs#remote-server-source-protocol"&gt;Remote Server Source Protocol&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;sync_once&lt;/code&gt; flag to sync the whole path immediately from remote disk server to local dest directory,&lt;br&gt;
like &lt;a href="https://github.com/no-src/gofs#sync-once"&gt;Sync Once&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;sync_cron&lt;/code&gt; flag to sync the whole path from remote disk server to local dest directory with cron,&lt;br&gt;
like &lt;a href="https://github.com/no-src/gofs#sync-cron"&gt;Sync Cron&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;force_checksum&lt;/code&gt; flag to force enable the checksum to compare whether the file is equal or not,&lt;br&gt;
like &lt;a href="https://github.com/no-src/gofs#local-disk"&gt;Local Disk&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;sync_delay&lt;/code&gt; flag like the &lt;a href="https://github.com/no-src/gofs#local-disk"&gt;Local Disk&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a remote disk client&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `users` flag with your real username and password&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rs://127.0.0.1:8105"&lt;/span&gt; &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-users&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gofs|password"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remote Push Server
&lt;/h3&gt;

&lt;p&gt;Start a &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; as a remote file source, then enable the remote push server with&lt;br&gt;
the &lt;code&gt;push_server&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;Pay attention to that remote push server users must have read and write permission at least, for&lt;br&gt;
example, &lt;code&gt;-users="gofs|password|rw"&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a remote disk server and enable the remote push server&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `tls_cert_file` and `tls_key_file` flags with your real cert files in the production environment&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `users` flag with complex username and password for security&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rs://127.0.0.1:8105?mode=server&amp;amp;local_sync_disabled=true&amp;amp;path=./source&amp;amp;fs_server=https://127.0.0.1"&lt;/span&gt; &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-users&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gofs|password|rw"&lt;/span&gt; &lt;span class="nt"&gt;-tls_cert_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cert.pem &lt;span class="nt"&gt;-tls_key_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;key.pem &lt;span class="nt"&gt;-push_server&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Remote Push Client
&lt;/h3&gt;

&lt;p&gt;Start a remote push client to sync change files to the &lt;a href="https://github.com/no-src/gofs#remote-push-server"&gt;Remote Push Server&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;chunk_size&lt;/code&gt; flag to set the chunk size of the big file to upload. The default value of &lt;code&gt;chunk_size&lt;/code&gt;&lt;br&gt;
is &lt;code&gt;1048576&lt;/code&gt;, which means &lt;code&gt;1MB&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;You can use the &lt;code&gt;checkpoint_count&lt;/code&gt; and &lt;code&gt;sync_delay&lt;/code&gt; flags like the &lt;a href="https://github.com/no-src/gofs#local-disk"&gt;Local Disk&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;More flag usage see &lt;a href="https://github.com/no-src/gofs#remote-disk-client"&gt;Remote Disk Client&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# Start a remote push client and enable local disk sync, sync the file changes from source path to the local dest path and the remote push server&lt;/span&gt;
&lt;span class="c"&gt;# Replace the `users` flag with your real username and password&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"./source"&lt;/span&gt; &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"rs://127.0.0.1:8105?local_sync_disabled=false&amp;amp;path=./dest"&lt;/span&gt; &lt;span class="nt"&gt;-users&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"gofs|password"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Relay
&lt;/h3&gt;

&lt;p&gt;If you need to synchronize files between two devices that are unable to establish a direct connection, you can use a&lt;br&gt;
reverse proxy as a relay server. In more detail, see also &lt;a href="https://github.com/no-src/gofs/blob/main/relay/README.md"&gt;Relay&lt;/a&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Remote Server Source Protocol
&lt;/h3&gt;

&lt;p&gt;The remote server source protocol is based on URI, see &lt;a href="https://www.rfc-editor.org/rfc/rfc3986.html"&gt;RFC 3986&lt;/a&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Scheme
&lt;/h4&gt;

&lt;p&gt;The scheme name is &lt;code&gt;rs&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Host
&lt;/h4&gt;

&lt;p&gt;The remote server source uses &lt;code&gt;0.0.0.0&lt;/code&gt; or other local ip address as host in &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt;&lt;br&gt;
mode, and use ip address or domain name as host in &lt;a href="https://github.com/no-src/gofs#remote-disk-client"&gt;Remote Disk Client&lt;/a&gt; mode.&lt;/p&gt;
&lt;h4&gt;
  
  
  Port
&lt;/h4&gt;

&lt;p&gt;The remote server source port, default is &lt;code&gt;8105&lt;/code&gt;.&lt;/p&gt;
&lt;h4&gt;
  
  
  Parameter
&lt;/h4&gt;

&lt;p&gt;Use the following parameters in &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; mode only.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;path&lt;/code&gt; the &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; actual local source directory&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;mode&lt;/code&gt; running mode, in &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; mode is &lt;code&gt;server&lt;/code&gt;, default is running
in &lt;a href="https://github.com/no-src/gofs#remote-disk-client"&gt;Remote Disk Client&lt;/a&gt; mode&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fs_server&lt;/code&gt; &lt;a href="https://github.com/no-src/gofs#file-server"&gt;File Server&lt;/a&gt; address, like &lt;code&gt;https://127.0.0.1&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;local_sync_disabled&lt;/code&gt; disabled &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; sync changes to its local dest path, &lt;code&gt;true&lt;/code&gt;
or &lt;code&gt;false&lt;/code&gt;, default is &lt;code&gt;false&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  Example
&lt;/h4&gt;

&lt;p&gt;For example, in &lt;a href="https://github.com/no-src/gofs#remote-disk-server"&gt;Remote Disk Server&lt;/a&gt; mode.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; rs://127.0.0.1:8105?mode=server&amp;amp;local_sync_disabled=true&amp;amp;path=./source&amp;amp;fs_server=https://127.0.0.1
 \_/  \_______/ \__/ \____________________________________________________________________________/
  |       |       |                                      |
scheme   host    port                                parameter
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Manage API
&lt;/h3&gt;

&lt;p&gt;Enable manage api base on &lt;a href="https://github.com/no-src/gofs#file-server"&gt;File Server&lt;/a&gt; by using the &lt;code&gt;manage&lt;/code&gt; flag.&lt;/p&gt;

&lt;p&gt;By default, allow to access manage api by private address and loopback address only.&lt;/p&gt;

&lt;p&gt;You can disable it by setting the &lt;code&gt;manage_private&lt;/code&gt; flag to &lt;code&gt;false&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-server&lt;/span&gt; &lt;span class="nt"&gt;-tls_cert_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;cert.pem &lt;span class="nt"&gt;-tls_key_file&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;key.pem &lt;span class="nt"&gt;-rand_user_count&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3 &lt;span class="nt"&gt;-manage&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Profiling API
&lt;/h4&gt;

&lt;p&gt;The pprof url address like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://127.0.0.1/manage/pprof/
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Config API
&lt;/h4&gt;

&lt;p&gt;Reading the program config, default return the config with &lt;code&gt;json&lt;/code&gt; format, and support &lt;code&gt;json&lt;/code&gt; and &lt;code&gt;yaml&lt;/code&gt; format&lt;br&gt;
currently.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://127.0.0.1/manage/config
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Or use the &lt;code&gt;format&lt;/code&gt; parameter to specific the config format.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://127.0.0.1/manage/config?format=yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Report API
&lt;/h4&gt;

&lt;p&gt;Use the &lt;code&gt;report&lt;/code&gt; flag to enable report api route, and start to collect the report data, need to enable the &lt;code&gt;manage&lt;/code&gt; flag&lt;br&gt;
first.&lt;/p&gt;

&lt;p&gt;The details of the report api see &lt;a href="https://github.com/no-src/gofs/blob/main/server/README.md#report-api"&gt;Report API&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://127.0.0.1/manage/report
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Logger
&lt;/h3&gt;

&lt;p&gt;Enable the file logger and console logger by default, and you can disable the file logger by setting the &lt;code&gt;log_file&lt;/code&gt; flag&lt;br&gt;
to &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_level&lt;/code&gt; flag to set the log level, default is &lt;code&gt;INFO&lt;/code&gt;, (&lt;code&gt;DEBUG=0&lt;/code&gt; &lt;code&gt;INFO=1&lt;/code&gt; &lt;code&gt;WARN=2&lt;/code&gt; &lt;code&gt;ERROR=3&lt;/code&gt;).&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_dir&lt;/code&gt; flag to set the directory of the log file, default is &lt;code&gt;./logs/&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_flush&lt;/code&gt; flag to enable auto flush log with interval, default is &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_flush_interval&lt;/code&gt; flag to set the log flush interval duration, default is &lt;code&gt;3s&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_event&lt;/code&gt; flag to enable the event log, write to file, default is &lt;code&gt;false&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;log_sample_rate&lt;/code&gt; flag to set the sample rate for the sample logger, and the value ranges from 0 to 1, default&lt;br&gt;
is &lt;code&gt;1&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="c"&gt;# set the logger config in "Local Disk" mode&lt;/span&gt;
&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./source &lt;span class="nt"&gt;-dest&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./dest &lt;span class="nt"&gt;-log_file&lt;/span&gt; &lt;span class="nt"&gt;-log_level&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;0 &lt;span class="nt"&gt;-log_dir&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="s2"&gt;"./logs/"&lt;/span&gt; &lt;span class="nt"&gt;-log_flush&lt;/span&gt; &lt;span class="nt"&gt;-log_flush_interval&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;3s &lt;span class="nt"&gt;-log_event&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Use Configuration File
&lt;/h3&gt;

&lt;p&gt;If you want, you can use a configuration file to replace all the flags.It supports &lt;code&gt;json&lt;/code&gt; and &lt;code&gt;yaml&lt;/code&gt; format currently.&lt;/p&gt;

&lt;p&gt;All the configuration fields are the same as the flags, you can refer to the &lt;a href="https://github.com/no-src/gofs/blob/main/conf/example"&gt;Configuration Example&lt;/a&gt;&lt;br&gt;
or the response of &lt;a href="https://github.com/no-src/gofs#config-api"&gt;Config API&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-conf&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./gofs.yaml
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Checksum
&lt;/h3&gt;

&lt;p&gt;You can use the &lt;code&gt;checksum&lt;/code&gt; flag to calculate the file checksum and print the result.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;chunk_size&lt;/code&gt;, &lt;code&gt;checkpoint_count&lt;/code&gt; and &lt;code&gt;checksum_algorithm&lt;/code&gt; flags are effective here the same as in&lt;br&gt;
the &lt;a href="https://github.com/no-src/gofs#local-disk"&gt;Local Disk&lt;/a&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-source&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;./gofs &lt;span class="nt"&gt;-checksum&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  For More Information
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Help Info
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-h&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Version Info
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  About Info
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nv"&gt;$ &lt;/span&gt;gofs &lt;span class="nt"&gt;-about&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>go</category>
      <category>opensource</category>
      <category>github</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
