Пример #1
0
 public static void Set()
 {
     Stop();
     DirectoryWithAcl.CreateDirectory(LibDirMnt, "755", "root", "root");
     MountManagement.Dir(LibDir);
     #region [    torrc generation    ]
     if (File.Exists(MainFilePath))
     {
         if (File.Exists(MainFilePathBackup))
         {
             File.Delete(MainFilePathBackup);
         }
         File.Copy(MainFilePath, MainFilePathBackup);
     }
     var lines = new List <string>();
     foreach (var svc in ServiceModel.Services)
     {
         if (string.IsNullOrEmpty(svc.Name) ||
             string.IsNullOrEmpty(svc.IpAddress) ||
             string.IsNullOrEmpty(svc.TorPort))
         {
             continue;
         }
         //HiddenServiceDir /var/lib/tor/hidden_service/
         //HiddenServicePort 80 127.0.0.1:8080
         var dire = $"{LibDirMnt}/{svc.Name}";
         DirectoryWithAcl.CreateDirectory(dire, "755", "root", "root");
         lines.Add($"HiddenServiceDir {dire}");
         lines.Add($"HiddenServicePort {svc.TorPort} {svc.IpAddress}");
     }
     FileWithAcl.WriteAllLines(MainFilePath, lines, "700", "tor", "root");
     #endregion
     Start();
 }
Пример #2
0
 public static void Remount()
 {
     while (MountHelper.IsAlreadyMounted(MainFilePath, DirsDirectoryPath))
     {
         MountHelper.Umount(MainFilePath);
     }
     MountManagement.File(MainFilePath);
 }