Skip to content

Commit

Permalink
renew chain faster
Browse files Browse the repository at this point in the history
  • Loading branch information
olebeck committed Jul 23, 2024
1 parent 162ee1c commit 4e5dc9a
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 9 deletions.
2 changes: 1 addition & 1 deletion utils/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func (c *chain) Expired() bool {
}
exp := mm["exp"].(float64)
t := time.Unix(int64(exp), 0)
return time.Until(t) < 30*time.Second
return time.Until(t) < 1*time.Hour
}

func (a *authsrv) readChain() (*chain, error) {
Expand Down
158 changes: 151 additions & 7 deletions utils/dumpstruct.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import (
)

func DumpStruct(f io.StringWriter, inputStruct any) {
dumpValue(f, 0, reflect.ValueOf(inputStruct), true)
dumpValue(f, 0, reflect.ValueOf(inputStruct), true, false)
}

func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool) {
func dumpValue(f io.StringWriter, level int, value reflect.Value, withType, isEntityMetadata bool) {
tabs := strings.Repeat("\t", level)

typeName := value.Type().String()
Expand All @@ -38,7 +38,7 @@ func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool)
f.WriteString(typeName + " Not Set")
} else {
f.WriteString(typeName + "{\n" + tabs + "\t")
dumpValue(f, level+1, val, false)
dumpValue(f, level+1, val, false, false)
f.WriteString("\n" + tabs + "}")
}
return
Expand All @@ -56,7 +56,7 @@ func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool)
fieldType := valueType.Field(i)
if fieldType.IsExported() {
f.WriteString(tabs + "\t" + fieldType.Name + ": ")
dumpValue(f, level+1, value.Field(i), true)
dumpValue(f, level+1, value.Field(i), true, fieldType.Name == "EntityMetadata")
f.WriteString(",\n")
} else {
f.WriteString(tabs + "\t" + fieldType.Name + " (unexported)\n")
Expand All @@ -81,13 +81,23 @@ func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool)
iter := value.MapRange()
for iter.Next() {
f.WriteString(tabs + "\t")
dumpValue(f, level+1, iter.Key(), false)
var kevV bool
if isEntityMetadata {
idx := int(iter.Key().Uint())
if idx < len(entityDataKeys) {
f.WriteString(entityDataKeys[idx][len("EntityDataKey"):])
kevV = true
}
}
if !kevV {
dumpValue(f, level+1, iter.Key(), false, false)
}
f.WriteString(": ")
elem := iter.Value()
if isAny {
elem = elem.Elem()
}
dumpValue(f, level+1, elem, isAny)
dumpValue(f, level+1, elem, isAny, false)
f.WriteString(",\n")
}
f.WriteString(tabs + "}")
Expand Down Expand Up @@ -128,7 +138,7 @@ func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool)
if isAny {
elem = elem.Elem()
}
dumpValue(f, level+1, elem, isAny)
dumpValue(f, level+1, elem, isAny, false)
if isStructish {
f.WriteString(",\n")
} else if i == value.Len()-1 {
Expand Down Expand Up @@ -174,3 +184,137 @@ func dumpValue(f io.StringWriter, level int, value reflect.Value, withType bool)
}
}
}

var entityDataKeys = []string{
"EntityDataKeyFlags",
"EntityDataKeyStructuralIntegrity",
"EntityDataKeyVariant",
"EntityDataKeyColorIndex",
"EntityDataKeyName",
"EntityDataKeyOwner",
"EntityDataKeyTarget",
"EntityDataKeyAirSupply",
"EntityDataKeyEffectColor",
"EntityDataKeyEffectAmbience",
"EntityDataKeyJumpDuration",
"EntityDataKeyHurt",
"EntityDataKeyHurtDirection",
"EntityDataKeyRowTimeLeft",
"EntityDataKeyRowTimeRight",
"EntityDataKeyValue",
"EntityDataKeyDisplayTileRuntimeID",
"EntityDataKeyDisplayOffset",
"EntityDataKeyCustomDisplay",
"EntityDataKeySwell",
"EntityDataKeyOldSwell",
"EntityDataKeySwellDirection",
"EntityDataKeyChargeAmount",
"EntityDataKeyCarryBlockRuntimeID",
"EntityDataKeyClientEvent",
"EntityDataKeyUsingItem",
"EntityDataKeyPlayerFlags",
"EntityDataKeyPlayerIndex",
"EntityDataKeyBedPosition",
"EntityDataKeyPowerX",
"EntityDataKeyPowerY",
"EntityDataKeyPowerZ",
"EntityDataKeyAuxPower",
"EntityDataKeyFishX",
"EntityDataKeyFishZ",
"EntityDataKeyFishAngle",
"EntityDataKeyAuxValueData",
"EntityDataKeyLeashHolder",
"EntityDataKeyScale",
"EntityDataKeyHasNPC",
"EntityDataKeyNPCData",
"EntityDataKeyActions",
"EntityDataKeyAirSupplyMax",
"EntityDataKeyMarkVariant",
"EntityDataKeyContainerType",
"EntityDataKeyContainerSize",
"EntityDataKeyContainerStrengthModifier",
"EntityDataKeyBlockTarget",
"EntityDataKeyInventory",
"EntityDataKeyTargetA",
"EntityDataKeyTargetB",
"EntityDataKeyTargetC",
"EntityDataKeyAerialAttack",
"EntityDataKeyWidth",
"EntityDataKeyHeight",
"EntityDataKeyFuseTime",
"EntityDataKeySeatOffset",
"EntityDataKeySeatLockPassengerRotation",
"EntityDataKeySeatLockPassengerRotationDegrees",
"EntityDataKeySeatRotationOffset",
"EntityDataKeySeatRotationOffstDegrees",
"EntityDataKeyDataRadius",
"EntityDataKeyDataWaiting",
"EntityDataKeyDataParticle",
"EntityDataKeyPeekID",
"EntityDataKeyAttachFace",
"EntityDataKeyAttached",
"EntityDataKeyAttachedPosition",
"EntityDataKeyTradeTarget",
"EntityDataKeyCareer",
"EntityDataKeyHasCommandBlock",
"EntityDataKeyCommandName",
"EntityDataKeyLastCommandOutput",
"EntityDataKeyTrackCommandOutput",
"EntityDataKeyControllingSeatIndex",
"EntityDataKeyStrength",
"EntityDataKeyStrengthMax",
"EntityDataKeyDataSpellCastingColor",
"EntityDataKeyDataLifetimeTicks",
"EntityDataKeyPoseIndex",
"EntityDataKeyDataTickOffset",
"EntityDataKeyAlwaysShowNameTag",
"EntityDataKeyColorTwoIndex",
"EntityDataKeyNameAuthor",
"EntityDataKeyScore",
"EntityDataKeyBalloonAnchor",
"EntityDataKeyPuffedState",
"EntityDataKeyBubbleTime",
"EntityDataKeyAgent",
"EntityDataKeySittingAmount",
"EntityDataKeySittingAmountPrevious",
"EntityDataKeyEatingCounter",
"EntityDataKeyFlagsTwo",
"EntityDataKeyLayingAmount",
"EntityDataKeyLayingAmountPrevious",
"EntityDataKeyDataDuration",
"EntityDataKeyDataSpawnTime",
"EntityDataKeyDataChangeRate",
"EntityDataKeyDataChangeOnPickup",
"EntityDataKeyDataPickupCount",
"EntityDataKeyInteractText",
"EntityDataKeyTradeTier",
"EntityDataKeyMaxTradeTier",
"EntityDataKeyTradeExperience",
"EntityDataKeySkinID",
"EntityDataKeySpawningFrames",
"EntityDataKeyCommandBlockTickDelay",
"EntityDataKeyCommandBlockExecuteOnFirstTick",
"EntityDataKeyAmbientSoundInterval",
"EntityDataKeyAmbientSoundIntervalRange",
"EntityDataKeyAmbientSoundEventName",
"EntityDataKeyFallDamageMultiplier",
"EntityDataKeyNameRawText",
"EntityDataKeyCanRideTarget",
"EntityDataKeyLowTierCuredTradeDiscount",
"EntityDataKeyHighTierCuredTradeDiscount",
"EntityDataKeyNearbyCuredTradeDiscount",
"EntityDataKeyNearbyCuredDiscountTimeStamp",
"EntityDataKeyHitBox",
"EntityDataKeyIsBuoyant",
"EntityDataKeyFreezingEffectStrength",
"EntityDataKeyBuoyancyData",
"EntityDataKeyGoatHornCount",
"EntityDataKeyBaseRuntimeID",
"EntityDataKeyMovementSoundDistanceOffset",
"EntityDataKeyHeartbeatIntervalTicks",
"EntityDataKeyHeartbeatSoundEvent",
"EntityDataKeyPlayerLastDeathPosition",
"EntityDataKeyPlayerLastDeathDimension",
"EntityDataKeyPlayerHasDied",
"EntityDataKeyCollisionBox",
}
3 changes: 2 additions & 1 deletion utils/proxy/session.go
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,8 @@ func (s *Session) connectClient(ctx context.Context, connect *utils.ConnectInfo)
}

s.listener, err = minecraft.ListenConfig{
StatusProvider: minecraft.NewStatusProvider(fmt.Sprintf("%s Proxy", connect.Name()), "Bedrocktool"),
AuthenticationDisabled: true,
StatusProvider: minecraft.NewStatusProvider(fmt.Sprintf("%s Proxy", connect.Name()), "Bedrocktool"),
PacketFunc: func(header packet.Header, payload []byte, src, dst net.Addr, timeReceived time.Time) {
if extraClientDebug != nil {
pk, ok := DecodePacket(header, payload, s.Client.ShieldID())
Expand Down

0 comments on commit 4e5dc9a

Please sign in to comment.