Skip to content

Commit

Permalink
base solution
Browse files Browse the repository at this point in the history
  • Loading branch information
Hidanio committed Feb 8, 2024
1 parent ea6996d commit 43fc6d4
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/main/kotlin/com/vk/admstorm/AdmStormStartupActivity.kt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import com.vk.admstorm.notifications.AdmNotification
import com.vk.admstorm.services.SentryService
import com.vk.admstorm.settings.AdmStormSettingsState
import com.vk.admstorm.ssh.SshConnectionService
import com.vk.admstorm.utils.MyUtils.changeConfigurationProcess
import com.vk.admstorm.utils.MyUtils.measureTime
import com.vk.admstorm.utils.ServerNameProvider
import com.vk.admstorm.utils.extensions.pluginEnabled
Expand Down Expand Up @@ -52,6 +53,7 @@ class AdmStormStartupActivity : ProjectActivity {
}
}

changeConfigurationProcess(project)
checkUpdates(project)

// Это необходимо чтобы для бенчмарков показывались все пункты в списке
Expand Down
63 changes: 63 additions & 0 deletions src/main/kotlin/com/vk/admstorm/utils/MyUtils.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package com.vk.admstorm.utils

import com.intellij.ide.BrowserUtil
import com.intellij.ide.util.PropertiesComponent
import com.intellij.openapi.application.ApplicationManager
import com.intellij.openapi.application.PathManager
import com.intellij.openapi.application.invokeAndWaitIfNeeded
import com.intellij.openapi.application.invokeLater
import com.intellij.openapi.diagnostic.Logger
import com.intellij.openapi.diagnostic.logger
import com.intellij.openapi.options.advanced.AdvancedSettings
import com.intellij.openapi.progress.PerformInBackgroundOption
import com.intellij.openapi.progress.ProgressIndicator
import com.intellij.openapi.progress.ProgressManager
Expand All @@ -17,6 +21,11 @@ import com.intellij.openapi.vfs.LocalFileSystem
import com.intellij.openapi.vfs.VirtualFile
import com.intellij.psi.PsiFile
import com.intellij.psi.PsiManager
import com.intellij.ssh.config.SshConnectionConfigService
import com.vk.admstorm.env.Env
import com.vk.admstorm.env.getByKey
import com.vk.admstorm.notifications.AdmNotification
import com.vk.admstorm.notifications.AdmWarningNotification
import com.vk.admstorm.utils.extensions.toHex
import org.apache.commons.io.input.ReversedLinesFileReader
import java.awt.Toolkit
Expand Down Expand Up @@ -229,4 +238,58 @@ object MyUtils {
}
}, delay)
}

fun changeSshConfiguration(configValue: Enum<SshConnectionConfigService.Kind>) {
AdvancedSettings.setEnum("ssh.config.backend", configValue)
}

fun changeConfigurationProcess(project: Project) {
val sshSettingValue =
AdvancedSettings.getEnum("ssh.config.backend", SshConnectionConfigService.Kind::class.java)
if (sshSettingValue.name.length == 6) { // is LEGACY, OPENSSH == 7
return
}

val docLink = Env.data.services.getByKey("sshLegacyWhy")?.url ?: return

val dntShow = PropertiesComponent.getInstance(project).getBoolean("dntShowSshLegacy")
if (dntShow) {
return
} else {
val isSshLegacy = PropertiesComponent.getInstance(project).getBoolean("isSshLegacy")
if (isSshLegacy) {
return
}

changeSshConfiguration(SshConnectionConfigService.Kind.LEGACY)

AdmNotification("We changed your ssh type to LEGACY")
.withActions(
AdmNotification.Action("Don`t show it again") { _, notification ->
invokeLater {
PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true)
notification.expire()
}
}
).withActions(
AdmNotification.Action("Rollback and turn off this notification") { _, notification ->
invokeLater {
changeSshConfiguration(SshConnectionConfigService.Kind.OPENSSH)
PropertiesComponent.getInstance(project).setValue("dntShowSshLegacy", true)
notification.expire()
}
}
)
.show(project)

AdmWarningNotification("We changed your ssh type to LEGACY", true).withActions(
AdmNotification.Action("Why do we need this?") { _, notification ->
invokeLater {
BrowserUtil.browse(docLink)
notification.expire()
}
}
).show(project)
}
}
}

0 comments on commit 43fc6d4

Please sign in to comment.