9front and more

This presents a very minor patch to allow Cloudflare's cloudflared to build for and operate on 9front and Plan9

Published by be0ba on

cloudflared for 9front

be0ba

The below patch should allow both building for and building on 9front. You may want to update DefaultUnixConfigLocation in config/configuration.go.

diff --git a/config/configuration.go b/config/configuration.go
index 5112d1ec..fe12e803 100644
--- a/config/configuration.go
+++ b/config/configuration.go
@@ -25,7 +25,7 @@ var (
    DefaultConfigFiles = []string{"config.yml", "config.yaml"}
 
    // DefaultUnixConfigLocation is the primary location to find a config file
-   DefaultUnixConfigLocation = "/usr/local/etc/cloudflared"
+   DefaultUnixConfigLocation = "/sys/lib/cloudflared"
 
    // DefaultUnixLogLocation is the primary location to find log files
    DefaultUnixLogLocation = "/var/log/cloudflared"
diff --git a/watcher/file.go b/watcher/file.go
index 369abe67..a00af9ef 100644
--- a/watcher/file.go
+++ b/watcher/file.go
@@ -1,62 +1,61 @@
 package watcher
 
 import (
-   "github.com/fsnotify/fsnotify"
+// "github.com/fsnotify/fsnotify"
 )
 
 // File is a file watcher that notifies when a file has been changed
 type File struct {
-   watcher  *fsnotify.Watcher
+   //  watcher  *fsnotify.Watcher
    shutdown chan struct{}
 }
 
 // NewFile is a standard constructor
 func NewFile() (*File, error) {
-   watcher, err := fsnotify.NewWatcher()
-   if err != nil {
-       return nil, err
-   }
-   f := &File{
-       watcher:  watcher,
-       shutdown: make(chan struct{}),
-   }
-   return f, nil
+   //  watcher, err := fsnotify.NewWatcher()
+   return nil, nil
+   //  f := &File{
+   //      watcher:  watcher,
+   //      shutdown: make(chan struct{}),
+   //  }
+   //  return f, nil
 }
 
 // Add adds a file to start watching
 func (f *File) Add(filepath string) error {
-   return f.watcher.Add(filepath)
+   return nil
+   //return f.watcher.Add(filepath)
 }
 
 // Shutdown stop the file watching run loop
 func (f *File) Shutdown() {
    // don't block if Start quit early
-   select {
-   case f.shutdown <- struct{}{}:
-   default:
-   }
+   // select {
+   // case f.shutdown <- struct{}{}:
+   // default:
+   // }
 }
 
 // Start is a runloop to watch for files changes from the file paths added from Add()
 func (f *File) Start(notifier Notification) {
-   for {
-       select {
-       case event, ok := <-f.watcher.Events:
-           if !ok {
-               return
-           }
-           if event.Op&fsnotify.Write == fsnotify.Write {
-               notifier.WatcherItemDidChange(event.Name)
-           }
-       case err, ok := <-f.watcher.Errors:
-           if !ok {
-               return
-           }
-           notifier.WatcherDidError(err)
+   // for {
+   //  select {
+   //  case event, ok := <-f.watcher.Events:
+   //      if !ok {
+   //          return
+   //      }
+   //      if event.Op&fsnotify.Write == fsnotify.Write {
+   //          notifier.WatcherItemDidChange(event.Name)
+   //      }
+   //  case err, ok := <-f.watcher.Errors:
+   //      if !ok {
+   //          return
+   //      }
+   //      notifier.WatcherDidError(err)
 
-       case <-f.shutdown:
-           f.watcher.Close()
-           return
-       }
-   }
+   //  case <-f.shutdown:
+   //      f.watcher.Close()
+   //      return
+   //  }
+   // }
 }

Tags: 9frontplan9cloudflarecloudflared.